dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Fix unnamed FK constraints parse for Sqlite

Open mvorisek opened this issue 3 years ago • 2 comments

Q A
Type bug
Fixed issues n/a

Summary

https://github.com/doctrine/dbal/pull/5490 must be merged first, this PR depends on it

fixes https://dbfiddle.uk/?rdbms=sqlite_3.27&fiddle=4651f0cc575a2f2df11856003d2e0af8

$i as a fallback name in https://github.com/doctrine/dbal/blob/d8fdd45b3a1e6b8d5eb9fa5a565c69d8de2cfda8/src/Schema/SqliteSchemaManager.php#L647 is wrong, as Sqlite constraint name cannot start with a number.

Empty string ('') as a fallback name must be used, so CONSTRAINT <numerical_name> FOREIGN KEY... is not generated for CREATE TABLE

https://www.sqlite.org/syntax/table-constraint.html

mvorisek avatar Jul 24 '22 23:07 mvorisek

Empty string ('') as a fallback name must be used, so CONSTRAINT <numerical_name> FOREIGN KEY... is not generated for CREATE TABLE

Please make sure the fix works when a table contains multiple unnamed foreign keys:

https://github.com/doctrine/dbal/blob/3ae5312bbd0b5fe271e90ca8d957038d14e1c840/src/Schema/SqliteSchemaManager.php#L446-L447

morozov avatar Jul 25 '22 21:07 morozov

Please note this PR requires https://github.com/doctrine/dbal/pull/5490 for the test, let's resolve/merge that PR first.

mvorisek avatar Jul 26 '22 19:07 mvorisek

Closing as it's most likely no longer relevant.

morozov avatar Sep 18 '22 18:09 morozov