1#include "duckdb/parser/constraint.hpp"
2
3#include "duckdb/common/printer.hpp"
4#include "duckdb/common/serializer.hpp"
5#include "duckdb/parser/constraints/list.hpp"
6
7using namespace duckdb;
8using namespace std;
9
10void Constraint::Serialize(Serializer &serializer) {
11 serializer.Write<ConstraintType>(type);
12}
13
14unique_ptr<Constraint> Constraint::Deserialize(Deserializer &source) {
15 auto type = source.Read<ConstraintType>();
16 switch (type) {
17 case ConstraintType::NOT_NULL:
18 return NotNullConstraint::Deserialize(source);
19 case ConstraintType::CHECK:
20 return CheckConstraint::Deserialize(source);
21 case ConstraintType::UNIQUE:
22 return UniqueConstraint::Deserialize(source);
23 default:
24 // don't know how to serialize this constraint type
25 return nullptr;
26 }
27}
28
29void Constraint::Print() {
30 Printer::Print(ToString());
31}
32