fix: ignore non-constants

This commit is contained in:
Levy A.
2025-05-23 23:50:02 -03:00
parent 15e0cab8d8
commit 41cb13aa74
2 changed files with 9 additions and 5 deletions

View File

@@ -805,14 +805,10 @@ impl ProgramBuilder {
_ => break 'value None,
};
let Some(default) = default else {
let Some(ast::Expr::Literal(ref literal)) = default else {
break 'value None;
};
let ast::Expr::Literal(ref literal) = default else {
panic!("column added by ALTER TABLE should be constant")
};
Some(match literal {
ast::Literal::Numeric(s) => match Numeric::from(s) {
Numeric::Null => Value::Null,

View File

@@ -51,6 +51,10 @@ do_execsql_test_on_specific_db {:memory:} alter-table-add-column-default {
CREATE INDEX idx ON test (b);
SELECT b FROM test WHERE b = 0.1;
ALTER TABLE test DROP a;
SELECT * FROM test;
} {
"1|0.1"
"2|0.1"
@@ -59,6 +63,10 @@ do_execsql_test_on_specific_db {:memory:} alter-table-add-column-default {
"0.1"
"0.1"
"0.1"
"0.1"
"0.1"
"0.1"
}
do_execsql_test_on_specific_db {:memory:} alter-table-drop-column {