Issue Bug Closed

#105441Autogeneration of selectSingle with foreign_table and a custom item with value null tries to create a varchar field

S P 10/24/24, 13:23 updated 03/31/26, 09:00

Description

The following auto-generates a varchar(255). I expected it to create an int unsigned DEFAULT NULL. Changing the custom item to 'value' => 0 auto-generates int unsigend NOT NULL DEFAULT 0.

If nullable fields are not desired here by the core, I’d expect that null would be treated for foreign_table-enabled selects implicitly as (int)0, not as varchar. Having a field holding an integer uid extended by an optional null being auto-cast to varchar seems wrong.

'config' => [
    'type' => 'select',
    'renderType' => 'selectSingle',
    'foreign_table' => 'some_foreign_table',
    'default' => null,
    'items' => [
        [
            'label' => 'Please choose!',
            'value' => null
        ]
    ]
]

Reviews 2