Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data types between XML, SQL and models do not match #1

Open
foobar13372 opened this issue Jan 17, 2020 · 2 comments
Open

Data types between XML, SQL and models do not match #1

foobar13372 opened this issue Jan 17, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@foobar13372
Copy link

The ext_tables.sql has for example
impressum text DEFAULT '' NOT NULL

MySQL can not have TEXT columns that are NOT NULL because NOT NULL implies having a DEFAULT, but TEXT can not have a default because it's a pointer-style column type (it's a sub-type of BLOB fields). So non-existing fields in the XML are stored as null, no matter what the column definition wishes to be. [NOT] NULL and DEFAULT are ignored in the SQL schema of BLOB fields.

The getter in the Extbase model is
public function getImpressum(): string
which will then throw an error of must be of the type string, null returned

Also on direct mapping of the XML into the models these properties are null which lead to the same error.

There are two ways of solving this:

  1. Return ?string, so make it nullable
  2. Initialize the property to string: protected $impressum = '';, so force it to string -- this works at least for the mapping from Database, not sure if it works when mapping directly from the XML.
@mgrundkoetter mgrundkoetter added the bug Something isn't working label Jan 17, 2020
@foobar13372
Copy link
Author

foobar13372 commented Jan 21, 2020

SQL defintion of the TEXT fields should just be field_name TEXT in ext_tables.sql.

Also all not-null TCA fields should provide a default in their TCA config. Even when the official docs not list the default setting for a field type (it's respected by the DataHandler anyways). Inline relations are such a case, for example. The TCA should have 'default' => 0 for inline fields even though default is not listed as a config option. Anotehr case is passthrough.

All this is needed to make the extension fully compatible to SQL strict mode (which TYPO3 core aims to fully support in the future).

@mgrundkoetter
Copy link
Member

@foobar13372 would you like to provide a PR for this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants