mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-18 07:34:19 +01:00
Merge 'Fix error handling when binding column references while translating the UPDATE statement' from Iaroslav Zeigerman
Closes #1968 Reviewed-by: bit-aloo (@Shourya742) Closes #2273
This commit is contained in:
@@ -212,7 +212,7 @@ pub fn bind_column_references(
|
||||
Ok(())
|
||||
} else {
|
||||
// Unquoted identifiers must resolve to columns - no fallback
|
||||
crate::bail_parse_error!("Column {} not found", id.as_str())
|
||||
crate::bail_parse_error!("no such column: {}", id.as_str())
|
||||
}
|
||||
}
|
||||
Expr::Qualified(tbl, id) => {
|
||||
@@ -236,7 +236,7 @@ pub fn bind_column_references(
|
||||
.is_some_and(|name| name.eq_ignore_ascii_case(&normalized_id))
|
||||
});
|
||||
let Some(col_idx) = col_idx else {
|
||||
crate::bail_parse_error!("Column {} not found", normalized_id);
|
||||
crate::bail_parse_error!("no such column: {}", normalized_id);
|
||||
};
|
||||
let col = tbl.columns().get(col_idx).unwrap();
|
||||
*expr = Expr::Column {
|
||||
|
||||
@@ -159,10 +159,10 @@ pub fn prepare_update_plan(
|
||||
for set in &mut body.sets {
|
||||
let ident = normalize_ident(set.col_names[0].as_str());
|
||||
let Some(col_index) = column_lookup.get(&ident) else {
|
||||
bail_parse_error!("Parse error: no such column: {}", ident);
|
||||
bail_parse_error!("no such column: {}", ident);
|
||||
};
|
||||
|
||||
let _ = bind_column_references(&mut set.expr, &mut table_references, None, connection);
|
||||
bind_column_references(&mut set.expr, &mut table_references, None, connection)?;
|
||||
|
||||
if let Some(idx) = set_clauses.iter().position(|(idx, _)| *idx == *col_index) {
|
||||
set_clauses[idx].1 = set.expr.clone();
|
||||
|
||||
@@ -726,7 +726,7 @@ def test_csv():
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
"SELECT c1 FROM t1;",
|
||||
lambda res: "Parse error: Column c1 not found" in res,
|
||||
lambda res: "Parse error: no such column: c1" in res,
|
||||
"Empty CSV table without header should not have columns other than 'c0'",
|
||||
)
|
||||
|
||||
@@ -738,7 +738,7 @@ def test_csv():
|
||||
)
|
||||
limbo.run_test_fn(
|
||||
"SELECT c0 FROM t2;",
|
||||
lambda res: "Parse error: Column c0 not found" in res,
|
||||
lambda res: "Parse error: no such column: c0" in res,
|
||||
"Empty CSV table with header should not have columns other than '(NULL)'",
|
||||
)
|
||||
|
||||
|
||||
@@ -269,4 +269,9 @@ do_execsql_test_on_specific_db {:memory:} update-single-rowid {
|
||||
INSERT INTO t VALUES (1);
|
||||
UPDATE t SET x = 2 WHERE x = 1;
|
||||
SELECT * FROM t;
|
||||
} {2}
|
||||
} {2}
|
||||
|
||||
do_execsql_test_in_memory_error_content update-set-expression-missing-identifier {
|
||||
CREATE TABLE t0 (c0 INT);
|
||||
UPDATE t0 SET c0 = 1, c0 = c1;
|
||||
} {".*no such column: c1.*"}
|
||||
|
||||
Reference in New Issue
Block a user