1#include "duckdb/planner/expression/bound_between_expression.hpp"
2
3using namespace duckdb;
4using namespace std;
5
6BoundBetweenExpression::BoundBetweenExpression(unique_ptr<Expression> input, unique_ptr<Expression> lower,
7 unique_ptr<Expression> upper, bool lower_inclusive, bool upper_inclusive)
8 : Expression(ExpressionType::COMPARE_BETWEEN, ExpressionClass::BOUND_BETWEEN, TypeId::BOOL), input(move(input)),
9 lower(move(lower)), upper(move(upper)), lower_inclusive(lower_inclusive), upper_inclusive(upper_inclusive) {
10}
11
12string BoundBetweenExpression::ToString() const {
13 return input->ToString() + " BETWEEN " + lower->ToString() + " AND " + upper->ToString();
14}
15
16bool BoundBetweenExpression::Equals(const BaseExpression *other_) const {
17 if (!BaseExpression::Equals(other_)) {
18 return false;
19 }
20 auto other = (BoundBetweenExpression *)other_;
21 if (!Expression::Equals(input.get(), other->input.get())) {
22 return false;
23 }
24 if (!Expression::Equals(lower.get(), other->lower.get())) {
25 return false;
26 }
27 if (!Expression::Equals(upper.get(), other->upper.get())) {
28 return false;
29 }
30 return lower_inclusive == other->lower_inclusive && upper_inclusive == other->upper_inclusive;
31}
32
33unique_ptr<Expression> BoundBetweenExpression::Copy() {
34 auto copy = make_unique<BoundBetweenExpression>(input->Copy(), lower->Copy(), upper->Copy(), lower_inclusive,
35 upper_inclusive);
36 copy->CopyProperties(*this);
37 return move(copy);
38}
39