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