diff --git a/core/translate/alter.rs b/core/translate/alter.rs index 6a764808d..e3ecf43ea 100644 --- a/core/translate/alter.rs +++ b/core/translate/alter.rs @@ -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(); diff --git a/testing/alter_table.test b/testing/alter_table.test index 6c18dff41..e9e83c403 100755 --- a/testing/alter_table.test +++ b/testing/alter_table.test @@ -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);