mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 09:14:24 +01:00
Merge 'Fix INSERT INTO t DEFAULT VALUES' from Jussi Saurio
Closes #3279 Closes #3291
This commit is contained in:
@@ -348,10 +348,24 @@ pub fn translate_insert(
|
||||
(result.num_result_cols, cursor_id)
|
||||
}
|
||||
}
|
||||
InsertBody::DefaultValues => (
|
||||
0,
|
||||
program.alloc_cursor_id(CursorType::BTreeTable(btree_table.clone())),
|
||||
),
|
||||
InsertBody::DefaultValues => {
|
||||
let num_values = table.columns().len();
|
||||
values = Some(
|
||||
table
|
||||
.columns()
|
||||
.iter()
|
||||
.map(|c| {
|
||||
c.default
|
||||
.clone()
|
||||
.unwrap_or(Box::new(ast::Expr::Literal(ast::Literal::Null)))
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
(
|
||||
num_values,
|
||||
program.alloc_cursor_id(CursorType::BTreeTable(btree_table.clone())),
|
||||
)
|
||||
}
|
||||
};
|
||||
let has_upsert = upsert_opt.is_some();
|
||||
|
||||
|
||||
@@ -633,3 +633,11 @@ do_execsql_test_on_specific_db {:memory:} boolean-literal-edgecase-false {
|
||||
CREATE TABLE false (id INTEGER, true TEXT);
|
||||
INSERT INTO false (id, true) VALUES (1, false) RETURNING id, false;
|
||||
} {1|0}
|
||||
|
||||
do_execsql_test_on_specific_db {:memory:} default-values-population {
|
||||
CREATE TABLE t (x INTEGER PRIMARY KEY, y DEFAULT 666, z);
|
||||
INSERT INTO t DEFAULT VALUES;
|
||||
INSERT INTO t DEFAULT VALUES;
|
||||
SELECT * FROM t;
|
||||
} {1|666|
|
||||
2|666|}
|
||||
Reference in New Issue
Block a user