Created classes for loading constraints.
This commit is contained in:
parent
8a27a1166f
commit
1727b0d645
5 changed files with 223 additions and 2 deletions
70
pglab/PgConstraint.cpp
Normal file
70
pglab/PgConstraint.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include "PgConstraint.h"
|
||||
|
||||
void operator<<(ConstraintType &s, const Pgsql::Value &v)
|
||||
{
|
||||
const char *c = v.c_str();
|
||||
switch (*c) {
|
||||
case 'c':
|
||||
s = ConstraintType::Check;
|
||||
break;
|
||||
case 'f':
|
||||
s = ConstraintType::ForeignKey;
|
||||
break;
|
||||
case 'p':
|
||||
s = ConstraintType::PrimaryKey;
|
||||
break;
|
||||
case 'u':
|
||||
s = ConstraintType::Unique;
|
||||
break;
|
||||
case 't':
|
||||
s = ConstraintType::ConstraintTrigger;
|
||||
break;
|
||||
case 'x':
|
||||
s = ConstraintType::ExclusionConstraint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void operator<<(ForeignKeyAction &s, const Pgsql::Value &v)
|
||||
{
|
||||
const char *c = v.c_str();
|
||||
switch (*c) {
|
||||
case 'a':
|
||||
s = ForeignKeyAction::NoAction;
|
||||
break;
|
||||
case 'r':
|
||||
s = ForeignKeyAction::Restrict;
|
||||
break;
|
||||
case 'c':
|
||||
s = ForeignKeyAction::Cascade;
|
||||
break;
|
||||
case 'n':
|
||||
s = ForeignKeyAction::SetNull;
|
||||
break;
|
||||
case 'd':
|
||||
s = ForeignKeyAction::SetDefault;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void operator<<(ForeignKeyMatch &s, const Pgsql::Value &v)
|
||||
{
|
||||
const char *c = v.c_str();
|
||||
switch (*c) {
|
||||
case 'f':
|
||||
s = ForeignKeyMatch::Full;
|
||||
break;
|
||||
case 'p':
|
||||
s = ForeignKeyMatch::Partial;
|
||||
break;
|
||||
case 's':
|
||||
s = ForeignKeyMatch::Simple;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PgConstraint::PgConstraint()
|
||||
{
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue