diff --git a/core/translate/expr.rs b/core/translate/expr.rs index ebe3e2116..b6207f9c7 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -3370,14 +3370,15 @@ pub fn bind_and_rewrite_expr<'a>( id.as_str() ); } + } else { + let col = + joined_table.table.columns().get(col_idx.unwrap()).unwrap(); + match_result = Some(( + joined_table.internal_id, + col_idx.unwrap(), + col.is_rowid_alias, + )); } - let col = - joined_table.table.columns().get(col_idx.unwrap()).unwrap(); - match_result = Some(( - joined_table.internal_id, - col_idx.unwrap(), - col.is_rowid_alias, - )); // 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, diff --git a/testing/join.test b/testing/join.test index a52973421..c14b96ab4 100755 --- a/testing/join.test +++ b/testing/join.test @@ -362,3 +362,25 @@ do_execsql_test_on_specific_db {:memory:} left-join-where-clause-regression { select t.a, s.a from t left join s on t.a=s.a where s.a = 2; } {2|2 2|2} + +# Regression test for: https://github.com/tursodatabase/turso/issues/3468 +do_execsql_test_on_specific_db {:memory:} left-join-using-star-vs-explicit { + create table t(a, tb); + create table s(a, sb); + insert into t values (1, 't1'), (2, 't2'); + insert into s values (1, 's1'), (3, 's3'); + select * from t left join s using(a); + select a, tb, sb from t left join s using(a); +} {1|t1|s1 +2|t2| +1|t1|s1 +2|t2|} + +do_execsql_test_on_specific_db {:memory:} left-join-using-null { + create table t(a, b); + create table s(a, b); + insert into t values (1, null), (2, null); + insert into s values (1, null), (2, null); + select a, b from t left join s using (a, b); +} {1| +2|}