Issue Feature Closed

#108741SQL auto-generation based on TCA does not respect the columns default value given in TCA

S P 01/23/26, 10:32 updated 04/17/26, 19:04

Description

The DefaultTcaSchema class only respects the TCA default value for TCA type check, in all other cases it just hard-coded uses the according “empty” value of the target SQL type. So empty string for string-style columns, 0 for integer-style columns and 0.0 for float-style columns, or null for nullable columns.

I expected that an explicit TCA default value is also considered by the SQL schema auto-creation.

Is there any specific reason why an explicitly configured default value is ignored? And what is so special about type check (the only where it is explicitly respected)? This actually lead to some confusion in one of our projects already, because we saw that check fields use the default and somehow also expected the other fields to behave the same.

Afaics this missing behaviour and the checkbox exception are both also not documented in TCA documentation,
neither in https://docs.typo3.org/m/typo3/reference-tca/13.4/en-us/ColumnsConfig/Type/Check/Index.html (or any other TCA type)
nor in https://docs.typo3.org/m/typo3/reference-coreapi/13.4/en-us/ExtensionArchitecture/FileStructure/ExtTablesSql.html#auto-generated-db-structure

Reported for v13 but afaics this is still valid on v14.

Reviews 1

History 78

  1. Garvin Hicking commented and changed tracker Bug Feature priority Should have Could have TYPO3 Version 13 <span data-processor="relativetime" data-value="2026-01-23T21:52:13+00:00" > 01/23/26, 21:52 </span>

    We recently had this on slack: https://typo3.slack.com/archives/C03AM9R17/p1768940190946839?thread_ts=1768939195.631289&channel=C03AM9R17&message_ts=1768940190.946839

    The gist is: TCA values are used for the FormEngine+DataHandler logics, and the defaults primarily apply to that domain, and not necessarily on DB level. So there might be valid use cases where raw DB access is used to fill in data, and where a TCA default (that could be dynamic!) should not apply on DB-level.

    If that default is needed, ext_tables.sql is a valid use case to utilize here.

    For checkbox fields it is quit certain to only use 0/1, that’s why it was put in there, I’d guess (no actual knowledge).

    So I’ll reclassify it as a feature to be evaluated. It’ll likely be a breaking change and might be problematic for data migration and integrity. So that may need to be configured as opt-in.

  2. S P commented <span data-processor="relativetime" data-value="2026-01-25T11:04:47+00:00" > 01/25/26, 11:04 </span>

    While I generally agree with your arguments, it must be noted that these arguments basically hold for the whole existance of DefaultTcaSchema, at all. It may very well be possible that for example a select field in TCA has items with values 0,1,2,3 and thus being auto-created as an UNSIGNED INT, while still being possible that a non-system-maintainer admin on some tree page did this in the backend UI pages DB field for PageTsConfig (totally unaware to a system-maintainer admin who is doing an upgrade, relying only on the stuff found in the code-base):

    TCEFORM {
        my_table {
            my_select_field {
                addItems {
                    someTextValue = Label
                }
                config {
                    default = someTextValue
                }
            }
        }
    }
    I think my main concern is not whether default is respected or not, but more like the general “inconsistency” or “exception amount” of this feature:
    • it only respects TCA (but not TSconfig)
    • it ignores default (but not for check)
    • then #105439 (MM supported but MM_match_fields ignored )
    • or #105438 (FOREIGN KEY on auto-created columns makes it crash, but normal INDEX does not )
    • it is documented in general (but not the exceptions/limitations)

    But these concerns are probably better put inside an epic (is there one?) about this feature. Since DefaultTcaSchema landed in core I very often had situations when I asked myself whether I encountered a bug, or a missing feature, or missing documentation or whether it is actually intended behaviour. The default one here is just another example (but I really try to like the feature :D ).

  3. Garvin Hicking commented <span data-processor="relativetime" data-value="2026-01-25T13:44:36+00:00" > 01/25/26, 13:44 </span>

    Thanks for the helpful details. I agree with you – there are “inconsistencies”, or as I’d like to put it, “a specific scope”.

    We should work on that. With Schema API at some point the tsconfig based changes will need addressing anyways. And I do think we can cover more ground to make the auto generation more clear.

    Luckily we do have the ext_tables logic still in place to remedy that. I think we can covert this to an epic if we flesh out the details and subtaks, good idea.

  4. Georg Ringer commented and changed status Under Review Closed <span data-processor="relativetime" data-value="2026-04-17T19:04:14+00:00" > 04/17/26, 19:04 </span>

    change has been merged, don’t know why issue has not been resolved