mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 10:08:20 +00:00
fix: default values not being converted to SQL
This commit is contained in:
parent
6945c0c09e
commit
326a8b39db
2 changed files with 8 additions and 5 deletions
|
@ -249,6 +249,10 @@ impl BTreeTable {
|
|||
sql.push_str(column.name.as_ref().expect("column name is None"));
|
||||
sql.push(' ');
|
||||
sql.push_str(&column.ty.to_string());
|
||||
if let Some(default) = &column.default {
|
||||
sql.push_str(" DEFAULT ");
|
||||
sql.push_str(&default.to_string());
|
||||
}
|
||||
}
|
||||
sql.push_str(");\n");
|
||||
sql
|
||||
|
|
|
@ -31,16 +31,15 @@ do_execsql_test_on_specific_db {:memory:} alter-table-add-column {
|
|||
|
||||
do_execsql_test_on_specific_db {:memory:} alter-table-add-column-typed {
|
||||
CREATE TABLE t(a);
|
||||
ALTER TABLE t ADD b TEXT;
|
||||
ALTER TABLE t ADD c INTEGER DEFAULT 0;
|
||||
ALTER TABLE t ADD b DEFAULT 0;
|
||||
|
||||
SELECT sql FROM sqlite_schema;
|
||||
|
||||
INSERT INTO t VALUES (1, 'a');
|
||||
INSERT INTO t (a) VALUES (1);
|
||||
SELECT * FROM t;
|
||||
} {
|
||||
"CREATE TABLE t(a, b TEXT, c INTEGER DEFAULT(0))"
|
||||
"1|a|0"
|
||||
"CREATE TABLE t(a, b DEFAULT 0)"
|
||||
"1|0"
|
||||
}
|
||||
|
||||
do_execsql_test_on_specific_db {:memory:} alter-table-drop-column {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue