Closed berkut1 closed 5 days ago
Hello!
When preparing to transition to DBAL4 and ORM3, I found a bug that has existed for a long time in DBAL3. The bug allows using VARCHAR without a length because when synchronizing schemas, the check for length = null for the string type will always return VARCHAR(255), even though in the database it will be VARCHAR. This is because the function does not know how to return VARCHAR https://github.com/doctrine/dbal/blob/0e3536ba088a749985c8801105b6b3ac6c1280b6/src/Platforms/PostgreSQLPlatform.php#L1129-L1133
VARCHAR
length = null
VARCHAR(255)
Therefore, VARCHAR will always equal VARCHAR(255) in DBAL3. However, DBAL4 can correctly determine the database schema and return VARCHAR (https://github.com/doctrine/dbal/blob/8edbce73bc1aa2251ba8c754fc440f8e02c661bc/src/Platforms/PostgreSQLPlatform.php#L637), which breaks all unlimited VARCHAR types in ORM3 that DBAL3 allowed through due to the bug.
A possible solution would be to allow ORM3 to use VARCHAR if length = null by removing the null check https://github.com/doctrine/orm/blob/9d4f54b9a476f13479c3845350b12c466873fc42/src/Tools/SchemaTool.php#L463-L465 if PostgreSQL (and possibly other platforms like SQLite?) is being used.
null
Thanks!
Feature Request
Summary
Hello!
When preparing to transition to DBAL4 and ORM3, I found a bug that has existed for a long time in DBAL3. The bug allows using
VARCHAR
without a length because when synchronizing schemas, the check forlength = null
for the string type will always returnVARCHAR(255)
, even though in the database it will beVARCHAR
. This is because the function does not know how to returnVARCHAR
https://github.com/doctrine/dbal/blob/0e3536ba088a749985c8801105b6b3ac6c1280b6/src/Platforms/PostgreSQLPlatform.php#L1129-L1133Therefore,
VARCHAR
will always equalVARCHAR(255)
in DBAL3. However, DBAL4 can correctly determine the database schema and returnVARCHAR
(https://github.com/doctrine/dbal/blob/8edbce73bc1aa2251ba8c754fc440f8e02c661bc/src/Platforms/PostgreSQLPlatform.php#L637), which breaks all unlimitedVARCHAR
types in ORM3 that DBAL3 allowed through due to the bug.A possible solution would be to allow ORM3 to use
VARCHAR
iflength = null
by removing thenull
check https://github.com/doctrine/orm/blob/9d4f54b9a476f13479c3845350b12c466873fc42/src/Tools/SchemaTool.php#L463-L465 if PostgreSQL (and possibly other platforms like SQLite?) is being used.Thanks!