#108741SQL auto-generation based on TCA does not respect the columns default value given in TCA
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
-
Garvin Hicking changed category <span data-processor="relativetime" data-value="2026-01-23T21:42:04+00:00" > 01/23/26, 21:42 </span>
-
Garvin Hicking commented and changed tracker
BugFeature priorityShould haveCould have TYPO3 Version13<span data-processor="relativetime" data-value="2026-01-23T21:52:13+00:00" > 01/23/26, 21:52 </span> -
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 aselectfield in TCA has items with values 0,1,2,3 and thus being auto-created as anUNSIGNED INT, while still being possible that a non-system-maintainer admin on some tree page did this in the backend UIpagesDB 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):
I think my main concern is not whetherTCEFORM { my_table { my_select_field { addItems { someTextValue = Label } config { default = someTextValue } } } }defaultis 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 forcheck) - then #105439 (MM supported but
MM_match_fieldsignored ) - or #105438 (
FOREIGN KEYon auto-created columns makes it crash, but normalINDEXdoes 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
DefaultTcaSchemalanded 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. Thedefaultone here is just another example (but I really try to like the feature :D ). -
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.
-
Garvin Hicking changed Duplicated by #108785 <span data-processor="relativetime" data-value="2026-01-27T10:50:54+00:00" > 01/27/26, 10:50 </span>
-
Gerrit Code Review pushed patch set 2 for main to change 92534 status
NewUnder Review <span data-processor="relativetime" data-value="2026-01-27T10:51:25+00:00" > 01/27/26, 10:51 </span> -
Georg Ringer commented and changed status
Under ReviewClosed <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
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.