Merge 'core/translate: Persist NOT NULL column constraint to schema table' from Preston Thorpe

closes #3391

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3402
This commit is contained in:
Preston Thorpe
2025-09-27 14:34:53 -04:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -1033,6 +1033,9 @@ impl BTreeTable {
sql.push(' ');
sql.push_str(&column.ty_str);
}
if column.notnull {
sql.push_str(" NOT NULL");
}
if column.unique {
sql.push_str(" UNIQUE");

View File

@@ -204,3 +204,10 @@ do_execsql_test_on_specific_db {:memory:} alter-table-rename-to-quoted-identifie
"CREATE INDEX idx ON \"t t\" (\"b b\")"
"2"
}
# https://github.com/tursodatabase/turso/issues/3391
do_execsql_test_on_specific_db {:memory:} alter-table-add-notnull-col {
CREATE TABLE t (a);
ALTER TABLE t ADD b NOT NULL;
SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = 't';
} {{CREATE TABLE t (a, b NOT NULL)}}