Fix another "should have been rewritten" translation panic

Closes #2158
This commit is contained in:
Jussi Saurio
2025-10-13 10:34:33 +03:00
parent 9e7c1e9061
commit 523b155df1
2 changed files with 29 additions and 1 deletions

View File

@@ -505,7 +505,7 @@ fn prepare_one_select_plan(
// Return the unoptimized query plan
Ok(plan)
}
ast::OneSelect::Values(values) => {
ast::OneSelect::Values(mut values) => {
if !order_by.is_empty() {
crate::bail_parse_error!("ORDER BY clause is not allowed with VALUES clause");
}
@@ -522,6 +522,21 @@ fn prepare_one_select_plan(
contains_aggregates: false,
});
}
for value_row in values.iter_mut() {
for value in value_row.iter_mut() {
bind_and_rewrite_expr(
value,
None,
None,
connection,
&mut program.param_ctx,
// Allow sqlite quirk of inserting "double-quoted" literals (which our AST maps as identifiers)
BindingBehavior::AllowUnboundIdentifiers,
)?;
}
}
let plan = SelectPlan {
join_order: vec![],
table_references: TableReferences::new(vec![], vec![]),

View File

@@ -48,3 +48,16 @@ do_execsql_test_skip_lines_on_specific_db 1 {:memory:} values-double-quotes-subq
.dbconfig dqs_dml on
SELECT * FROM (VALUES ("subquery_string"));
} {subquery_string}
# regression test for: https://github.com/tursodatabase/turso/issues/2158
do_execsql_test_on_specific_db {:memory:} values-between {
CREATE TABLE t0 (c0);
INSERT INTO t0 VALUES ((0 BETWEEN 0 AND 0)), (0);
SELECT * FROM t0;
} {1
0}
do_execsql_test_in_memory_any_error values-illegal-column-ref {
CREATE TABLE t0 (c0);
INSERT INTO t0 VALUES (c0);
}