AST Filter: Field without table name should refer to main table instead of joined one by default
gitmalong opened this issue · comments
gitmalong commented
let mut builder = table("a")
.select()
.left_join("b")
.hash_executor(
format!("b.a_id"),
format!("a.id"),
)
.filter(col("year").eq(num(year)));
I found that the filter checks year
against table b
. I would have expected it to check against the main table a
when no table is specified.
Taehoon Moon commented
Thanks! This is not only for the AST builder, but also happens same in SQL.
e.g.
SELECT *
FROM a
LEFT JOIN b
WHERE id = a.id;
id
without specifying table finds b
table for the first.
Currently this implementation is intended behavior but I wonder other db cases.