diff --git a/src/binder/expr.rs b/src/binder/expr.rs index c147ed76..53c4958a 100644 --- a/src/binder/expr.rs +++ b/src/binder/expr.rs @@ -342,7 +342,7 @@ impl<'a, T: Transaction> Binder<'a, '_, T> { try_default!(&full_name.0, full_name.1); } if let Some(table) = full_name.0.or(bind_table_name) { - let source = self.context.bind_source(&table, self.parent)?; + let source = self.context.bind_source(&table)?; let schema_buf = self.table_schema_buf.entry(Arc::new(table)).or_default(); Ok(ScalarExpression::ColumnRef( diff --git a/src/binder/mod.rs b/src/binder/mod.rs index 068d6f81..7e9e5340 100644 --- a/src/binder/mod.rs +++ b/src/binder/mod.rs @@ -272,18 +272,12 @@ impl<'a, T: Transaction> BinderContext<'a, T> { Ok(source) } - pub fn bind_source<'b: 'a>( - &self, - table_name: &str, - parent: Option<&'b Binder<'a, 'b, T>>, - ) -> Result<&Source, DatabaseError> { + pub fn bind_source<'b: 'a>(&self, table_name: &str) -> Result<&Source, DatabaseError> { if let Some(source) = self.bind_table.iter().find(|((t, alias, _), _)| { t.as_str() == table_name || matches!(alias.as_ref().map(|a| a.as_str() == table_name), Some(true)) }) { Ok(source.1) - } else if let Some(binder) = parent { - binder.context.bind_source(table_name, binder.parent) } else { Err(DatabaseError::InvalidTable(table_name.into())) }