mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-07 18:24:20 +01:00
Merge 'translate/select: Fix rewriting Rowid expression when no btree table exists in joined table refs ' from Preston Thorpe
closes https://github.com/tursodatabase/turso/issues/3667 Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #3754
This commit is contained in:
@@ -3495,14 +3495,18 @@ pub fn bind_and_rewrite_expr<'a>(
|
||||
));
|
||||
}
|
||||
// only if we haven't found a match, check for explicit rowid reference
|
||||
} else if let Some(row_id_expr) = parse_row_id(
|
||||
&normalized_id,
|
||||
referenced_tables.joined_tables()[0].internal_id,
|
||||
|| referenced_tables.joined_tables().len() != 1,
|
||||
)? {
|
||||
*expr = row_id_expr;
|
||||
|
||||
return Ok(WalkControl::Continue);
|
||||
} else {
|
||||
let is_btree_table = matches!(joined_table.table, Table::BTree(_));
|
||||
if is_btree_table {
|
||||
if let Some(row_id_expr) = parse_row_id(
|
||||
&normalized_id,
|
||||
referenced_tables.joined_tables()[0].internal_id,
|
||||
|| referenced_tables.joined_tables().len() != 1,
|
||||
)? {
|
||||
*expr = row_id_expr;
|
||||
return Ok(WalkControl::Continue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1060,4 +1060,17 @@ do_execsql_test_in_memory_any_error limit-column-reference-error {
|
||||
do_execsql_test select-binary-collation {
|
||||
SELECT 'a' = 'A';
|
||||
SELECT 'a' = 'a';
|
||||
} {0 1}
|
||||
} {0 1}
|
||||
|
||||
# https://github.com/tursodatabase/turso/issues/3667 regression test
|
||||
do_execsql_test_in_memory_error_content rowid-select-from-clause-subquery {
|
||||
CREATE TABLE t(a);
|
||||
SELECT rowid FROM (SELECT * FROM t);
|
||||
} {"no such column: rowid"}
|
||||
|
||||
do_execsql_test_on_specific_db {:memory:} rowid-select-from-clause-subquery-explicit-works {
|
||||
CREATE TABLE t(a);
|
||||
INSERT INTO t values ('abc');
|
||||
SELECT rowid,a FROM (SELECT rowid,a FROM t);
|
||||
} {1|abc}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user