-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improve tests on reserved keyword #6897
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
Improve tests on reserved keyword #6897
Conversation
33cc911
to
817590e
Compare
Looks like there is an issue with SQLite Table comment (https://github.com/doctrine/dbal/actions/runs/14295646317/job/40062871091). I dug a bit and it looks like it should be added in dbal/src/Platforms/SQLitePlatform.php Lines 293 to 298 in c4ae845
But somehow the dbal/src/Platforms/AbstractPlatform.php Line 867 in c4ae845
(Here we do not get inside anyway as For the record, it works if I create and read the commentas manually: $connection->executeStatement(<<<'SQL'
CREATE TABLE "user" --table comment
(
"user" INT --column comment
)
SQL
);
$schemaManager = $connection->createSchemaManager();
$table = schemaManager->introspectTable('"user"');
var_dump($table->getComment()); // "table comment"
var_dump($table->getColumn('user')->getComment()); // "column comment" |
@homersimpsons I recently added a similar change to another test (see #6893). As we removed reserved keyword lists from 5.0 (see #6589), there isn't any difference in handling the names that are reserved keywords (e.g. "select") and any other quoted identifiers (e.g. the ones that contain letters in the upper and lower case). As for why the updated test is failing ,
I don't see this option being set on the table in your updated test. |
- Use `select` as reserved keyword (user does not seem to be reserved on sqlite) - Ensure comments are retrieved correctly
817590e
to
7bdadf3
Compare
In fact your added test should be enough.
Oh in fact, sorry, I updated the test, but when I run them locally on sqlite I have I can fix this with a slight modification of the -{[\s(,](?:\Wselect\W|\W"select"\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i
+{[\s(,](?:\Wselect\W|\W"select"\W)\s(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s+--[^\n]*\n?)+)}i
^^ require a space ^ require at least a space But I do not know if this fix is correct, i.e. how constrained is the create table output in sqlite. From my understanding it just returns the exact CREATE table "test" (/* abc */ "id" INTEGER, "test" INTEGER --abc
);
SELECT sql FROM sqlite_master WHERE type = 'table' and name = 'test';
/*
CREATE TABLE "test" (/* abc */ "id" INTEGER, "test" INTEGER --abc
)
*/
ALTER TABLE "test" ADD COLUMN "foo" INTEGER; --no comment
SELECT sql FROM sqlite_master WHERE type = 'table' and name = 'test';
/*
CREATE TABLE "test" (/* abc */ "id" INTEGER, "test" INTEGER --abc
, "foo" INTEGER)
*/
ALTER TABLE "test" DROP COLUMN "test";
SELECT sql FROM sqlite_master WHERE type = 'table' and name = 'test';
/*
CREATE TABLE "test" (/* abc */ "id" INTEGER, "foo" INTEGER)
*/ |
If that's an issue, I think it's worth being reproduced and tracked separately, not as part of this PR. As we agreed, there is an existing test that covers this scenario. A few facts on the support for table/column comments on SQLite:
|
Summary
select
as reserved keyword (user does not seem to be reserved on sqlite)