1#include "duckdb/parser/expression/comparison_expression.hpp"
2
3#include "duckdb/common/exception.hpp"
4#include "duckdb/common/serializer.hpp"
5#include "duckdb/parser/expression/cast_expression.hpp"
6
7using namespace duckdb;
8using namespace std;
9
10ComparisonExpression::ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
11 unique_ptr<ParsedExpression> right)
12 : ParsedExpression(type, ExpressionClass::COMPARISON) {
13 this->left = move(left);
14 this->right = move(right);
15}
16
17string ComparisonExpression::ToString() const {
18 return left->ToString() + ExpressionTypeToOperator(type) + right->ToString();
19}
20
21bool ComparisonExpression::Equals(const ComparisonExpression *a, const ComparisonExpression *b) {
22 if (!a->left->Equals(b->left.get())) {
23 return false;
24 }
25 if (!a->right->Equals(b->right.get())) {
26 return false;
27 }
28 return true;
29}
30
31unique_ptr<ParsedExpression> ComparisonExpression::Copy() const {
32 auto copy = make_unique<ComparisonExpression>(type, left->Copy(), right->Copy());
33 copy->CopyProperties(*this);
34 return move(copy);
35}
36
37void ComparisonExpression::Serialize(Serializer &serializer) {
38 ParsedExpression::Serialize(serializer);
39 left->Serialize(serializer);
40 right->Serialize(serializer);
41}
42
43unique_ptr<ParsedExpression> ComparisonExpression::Deserialize(ExpressionType type, Deserializer &source) {
44 auto left_child = ParsedExpression::Deserialize(source);
45 auto right_child = ParsedExpression::Deserialize(source);
46 return make_unique<ComparisonExpression>(type, move(left_child), move(right_child));
47}
48