Skip to content

Commit

Permalink
Add an option to specify other constraints that conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
shitzuu committed Sep 1, 2024
1 parent 0278ed7 commit 9bd2763
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/dev/shiza/bulbasaur/create/table/TableQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public Table column(final @NotNull String name, final @NotNull ColumnDefinition.
}

@Override
public Table constraint(final @NotNull String name, final @NotNull String condition) {
constraints.add(new Constraint(name, condition));
public Table constraint(final @NotNull String name, final @NotNull String declaration) {
constraints.add(new Constraint(name, declaration));
return this;
}

@Override
public Table constraint(final @NotNull String name, final @NotNull Condition condition) {
return constraint(name, condition.generate());
return constraint(name, "CHECK (\n" + condition.generate() + "\n)");
}

@Override
Expand All @@ -77,5 +77,5 @@ public List<Constraint> getConstraints() {

record Column(String name, String declaration) {}

record Constraint(String name, String condition) {}
record Constraint(String name, String declaration) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private String getGeneratedConstraintClause(final Constraint constraint) {
+ constraint.name()
+ "_constraint"
+ "\nCHECK (\n"
+ constraint.condition()
+ constraint.declaration()
+ "\n)";
}

Expand Down

0 comments on commit 9bd2763

Please sign in to comment.