From 8867d8cdb69d82b7a3e8dcd9410d32bf71647628 Mon Sep 17 00:00:00 2001 From: "Levy A." Date: Fri, 5 Sep 2025 20:35:08 -0300 Subject: [PATCH] feat: add more alter table test cases --- core/translate/alter.rs | 1 + testing/alter_table.test | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/core/translate/alter.rs b/core/translate/alter.rs index a22800c32..738d88a7d 100644 --- a/core/translate/alter.rs +++ b/core/translate/alter.rs @@ -192,6 +192,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);