Merge 'Add quoted identifier test cases for ALTER TABLE' from Levy A.

Resolves #2093
There is a small incompatibility on how we quote the added column on the
final schema, but doesn't change any behavior.

Closes #2943
This commit is contained in:
Pekka Enberg
2025-09-16 11:46:12 +03:00
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@@ -198,6 +198,7 @@ pub fn translate_alter_table(
}
}
// TODO: All quoted ids will be quoted with `[]`, we should store some info from the parsed AST
btree.columns.push(column.clone());
let sql = btree.to_sql();

View File

@@ -19,6 +19,14 @@ do_execsql_test_on_specific_db {:memory:} alter-table-rename-column {
"CREATE INDEX i ON t (b)"
}
do_execsql_test_on_specific_db {:memory:} alter-table-rename-quoted-column {
CREATE TABLE t (a INTEGER);
ALTER TABLE t RENAME a TO "ab cd";
SELECT sql FROM sqlite_schema;
} {
"CREATE TABLE t (\"ab cd\" INTEGER)"
}
do_execsql_test_on_specific_db {:memory:} alter-table-add-column {
CREATE TABLE t (a);
INSERT INTO t VALUES (1);
@@ -74,6 +82,14 @@ do_execsql_test_on_specific_db {:memory:} alter-table-add-column-default {
"0.1|hello"
}
do_execsql_test_on_specific_db {:memory:} alter-table-add-quoted-column {
CREATE TABLE test (a);
ALTER TABLE test ADD COLUMN [b c];
SELECT sql FROM sqlite_schema;
} {
"CREATE TABLE test (a, [b c])"
}
do_execsql_test_on_specific_db {:memory:} alter-table-drop-column {
CREATE TABLE t (a, b);
INSERT INTO t VALUES (1, 1), (2, 2), (3, 3);