Skip to content

Commit

Permalink
feat: Allow LogicalExpr to return dynamic type depend on operands
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Dec 20, 2024
1 parent 6858d8c commit 1687f3a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/gitql-ast/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,13 @@ impl Expr for LogicalExpr {
}

fn expr_type(&self) -> Box<dyn DataType> {
Box::new(BoolType)
let lhs_type = self.left.expr_type();
let rhs_type = &self.right.expr_type();
match self.operator {
BinaryLogicalOperator::Or => lhs_type.logical_or_op_result_type(rhs_type),
BinaryLogicalOperator::And => lhs_type.logical_and_op_result_type(rhs_type),
BinaryLogicalOperator::Xor => lhs_type.logical_xor_op_result_type(rhs_type),
}
}

fn as_any(&self) -> &dyn Any {
Expand Down

0 comments on commit 1687f3a

Please sign in to comment.