Skip to content

Commit

Permalink
fix: bind error of the same fields in different tables in in subquery
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Mar 16, 2024
1 parent f02a5ee commit 3b71e7f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/binder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
subquery,
negated,
} => {
let left_expr = Box::new(self.bind_expr(expr)?);
let (sub_query, column) = self.bind_subquery(subquery)?;

if !self.context.is_step(&QueryBindStep::Where) {
Expand All @@ -137,7 +138,7 @@ impl<'a, T: Transaction> Binder<'a, T> {

Ok(ScalarExpression::Binary {
op: expression::BinaryOperator::Eq,
left_expr: Box::new(self.bind_expr(expr)?),
left_expr,
right_expr: Box::new(alias_expr),
ty: LogicalType::Boolean,
})
Expand Down Expand Up @@ -295,7 +296,7 @@ impl<'a, T: Transaction> Binder<'a, T> {
} else {
// handle col syntax
let mut got_column = None;
for table_catalog in self.context.bind_table.values() {
for table_catalog in self.context.bind_table.values().rev() {
if let Some(column_catalog) = table_catalog.get_column_by_name(&column_name) {
got_column = Some(column_catalog);
}
Expand Down

0 comments on commit 3b71e7f

Please sign in to comment.