From 9bd2763763683396dd1caffffbd8049ab3f24c4d Mon Sep 17 00:00:00 2001 From: shitzuu Date: Sun, 1 Sep 2024 21:28:26 +0200 Subject: [PATCH] Add an option to specify other constraints that conditions --- src/dev/shiza/bulbasaur/create/table/TableQuery.java | 8 ++++---- .../shiza/bulbasaur/create/table/TableQueryGenerator.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dev/shiza/bulbasaur/create/table/TableQuery.java b/src/dev/shiza/bulbasaur/create/table/TableQuery.java index 21d3d7e..fab4d0b 100644 --- a/src/dev/shiza/bulbasaur/create/table/TableQuery.java +++ b/src/dev/shiza/bulbasaur/create/table/TableQuery.java @@ -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 @@ -77,5 +77,5 @@ public List getConstraints() { record Column(String name, String declaration) {} - record Constraint(String name, String condition) {} + record Constraint(String name, String declaration) {} } diff --git a/src/dev/shiza/bulbasaur/create/table/TableQueryGenerator.java b/src/dev/shiza/bulbasaur/create/table/TableQueryGenerator.java index 85ed2b3..e1b7b87 100644 --- a/src/dev/shiza/bulbasaur/create/table/TableQueryGenerator.java +++ b/src/dev/shiza/bulbasaur/create/table/TableQueryGenerator.java @@ -50,7 +50,7 @@ private String getGeneratedConstraintClause(final Constraint constraint) { + constraint.name() + "_constraint" + "\nCHECK (\n" - + constraint.condition() + + constraint.declaration() + "\n)"; }