1 | #include "duckdb/parser/constraints/check_constraint.hpp" |
---|---|
2 | |
3 | #include "duckdb/common/field_writer.hpp" |
4 | |
5 | namespace duckdb { |
6 | |
7 | CheckConstraint::CheckConstraint(unique_ptr<ParsedExpression> expression) |
8 | : Constraint(ConstraintType::CHECK), expression(std::move(expression)) { |
9 | } |
10 | |
11 | string CheckConstraint::ToString() const { |
12 | return "CHECK("+ expression->ToString() + ")"; |
13 | } |
14 | |
15 | unique_ptr<Constraint> CheckConstraint::Copy() const { |
16 | return make_uniq<CheckConstraint>(args: expression->Copy()); |
17 | } |
18 | |
19 | void CheckConstraint::Serialize(FieldWriter &writer) const { |
20 | writer.WriteSerializable(element: *expression); |
21 | } |
22 | |
23 | unique_ptr<Constraint> CheckConstraint::Deserialize(FieldReader &source) { |
24 | auto expression = source.ReadRequiredSerializable<ParsedExpression>(); |
25 | return make_uniq<CheckConstraint>(args: std::move(expression)); |
26 | } |
27 | |
28 | } // namespace duckdb |
29 |