Skip to content
Snippets Groups Projects
Commit 9cdfa70c authored by Stefan Bürk's avatar Stefan Bürk
Browse files

[BUGFIX] Adopt doctrine/dbal sqlite autoincrement detection

sqlite basicly knows about two kind of autoincrement column
definition. One which is an alias on the provided "row_id"
field for an integer field which is also the single field
of the primary key index. And the second one with a real
autoincrement notation, which is not an alias like the first
one. Basicly this differes in some behaviours, mainly that
the second one will never reassign ids which has been deleted.
The first one will eventually reassign deleted ids to fill up
spaces in between.

This counts for inserts where the column data has a null value.
If a real value is provided, this will be used.

"ext:indexed_search" defines some tables with integer columns
which are the primary key, which are not flagged as autoincrement
fields. This is not needed as the inserted data always uses pre
calculated hash values.

This works pretty fine on most dbms. sqlite automatically assumes
the autoincrement field (row_id) alias type for creation, which
works so far pretty well.

doctrine/dbal uses 'PRAGMA table_info(<table-name>)' to read
the table structure, which do not containts the information
if the field is created with the AUTOINCREMENT keyword or not.
Reading the table struncture from a sqlite database sets the
"autoincrement: true" value for colums of type integer, if
they are the only included column of an primary key.

On the other side, reading/building the meta schema based on
the TYPO3 "ext_tables.sql" files of extensions and using the
default table definition building based on TCA, the column
will get "autoincrement: false" if the auto_increment keyword
is not used.

This will popup these tables again and again, as it always will
detect the column as changed, because of the not matching column
autoincrement value.

This patch adopts this assumptions from doctrine/dbal and set the
autoincrement to true, if a table has one primary key colum of
type integer without a autoincremet flag. This will create the
real autoincrement column instead, which is a safer variant for it.

doctrine/dbal added this detection based on these assumptions with:
https://github.com/doctrine/dbal/commit/33555d36e7e7d07a5880e01

Resolves: #97447
Releases: main, 11.5
Change-Id: I410da0db7a8f0748e5a8ee099cd36ee121cafa60
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74458


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent d492a4ee
Branches
Tags
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment