[jOOQ/jOOQ#11816] Add missing ConstraintTypeStep.primaryKey(Collection<? extends Field<?>>) and related overloads
This commit is contained in:
parent
9023e1fcd6
commit
fc9b5d04f7
@ -37,6 +37,7 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* The step in the {@link Constraint} construction DSL API that allows for
|
||||
@ -59,6 +60,12 @@ public interface ConstraintForeignKeyReferencesStepN {
|
||||
*/
|
||||
ConstraintForeignKeyOnStep references(String table, String... fields);
|
||||
|
||||
/**
|
||||
* Add a <code>REFERENCES</code> clause to the <code>CONSTRAINT</code>,
|
||||
* referencing a key by column names.
|
||||
*/
|
||||
ConstraintForeignKeyOnStep references(String table, Collection<? extends String> fields);
|
||||
|
||||
/**
|
||||
* Add a <code>REFERENCES</code> clause to the <code>CONSTRAINT</code>,
|
||||
* implicitly referencing the primary key.
|
||||
@ -71,6 +78,12 @@ public interface ConstraintForeignKeyReferencesStepN {
|
||||
*/
|
||||
ConstraintForeignKeyOnStep references(Name table, Name... fields);
|
||||
|
||||
/**
|
||||
* Add a <code>REFERENCES</code> clause to the <code>CONSTRAINT</code>,
|
||||
* referencing a key by column names.
|
||||
*/
|
||||
ConstraintForeignKeyOnStep references(Name table, Collection<? extends Name> fields);
|
||||
|
||||
/**
|
||||
* Add a <code>REFERENCES</code> clause to the <code>CONSTRAINT</code>,
|
||||
* implicitly referencing the primary key.
|
||||
@ -82,4 +95,10 @@ public interface ConstraintForeignKeyReferencesStepN {
|
||||
* referencing a key by column names.
|
||||
*/
|
||||
ConstraintForeignKeyOnStep references(Table<?> table, Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Add a <code>REFERENCES</code> clause to the <code>CONSTRAINT</code>,
|
||||
* referencing a key by column names.
|
||||
*/
|
||||
ConstraintForeignKeyOnStep references(Table<?> table, Collection<? extends Field<?>> fields);
|
||||
}
|
||||
|
||||
@ -66,6 +66,8 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -115,6 +117,13 @@ public interface ConstraintTypeStep extends ConstraintFinalStep {
|
||||
@Support
|
||||
ConstraintEnforcementStep primaryKey(Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Create a <code>PRIMARY KEY</code> constraint.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
ConstraintEnforcementStep primaryKey(Collection<? extends Field<?>> fields);
|
||||
|
||||
/**
|
||||
* Add a <code>FOREIGN KEY</code> clause to the <code>CONSTRAINT</code>.
|
||||
*/
|
||||
@ -136,6 +145,13 @@ public interface ConstraintTypeStep extends ConstraintFinalStep {
|
||||
@Support
|
||||
ConstraintForeignKeyReferencesStepN foreignKey(Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Add a <code>FOREIGN KEY</code> clause to the <code>CONSTRAINT</code>.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
ConstraintForeignKeyReferencesStepN foreignKey(Collection<? extends Field<?>> fields);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -623,6 +639,13 @@ public interface ConstraintTypeStep extends ConstraintFinalStep {
|
||||
@Support
|
||||
ConstraintEnforcementStep unique(Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Create a <code>UNIQUE</code> constraint.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
ConstraintEnforcementStep unique(Collection<? extends Field<?>> fields);
|
||||
|
||||
/**
|
||||
* Create a <code>CHECK</code> constraint.
|
||||
*/
|
||||
|
||||
@ -145,6 +145,17 @@ public interface CreateTableConstraintStep extends CreateTableIndexStep {
|
||||
@Support
|
||||
CreateTableConstraintStep primaryKey(Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Convenience method to add an unnamed (system named)
|
||||
* <code>PRIMARY KEY</code> constraint to the table.
|
||||
* <p>
|
||||
* This does the same as adding {@link DSL#primaryKey(Field...)} via
|
||||
* {@link #constraint(Constraint)} explicitly.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support
|
||||
CreateTableConstraintStep primaryKey(Collection<? extends Field<?>> fields);
|
||||
|
||||
/**
|
||||
* Convenience method to add an unnamed (system named) <code>UNIQUE</code>
|
||||
* constraint to the table.
|
||||
@ -178,6 +189,17 @@ public interface CreateTableConstraintStep extends CreateTableIndexStep {
|
||||
@Support
|
||||
CreateTableConstraintStep unique(Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Convenience method to add an unnamed (system named) <code>UNIQUE</code>
|
||||
* constraint to the table.
|
||||
* <p>
|
||||
* This does the same as adding {@link DSL#unique(Field...)} via
|
||||
* {@link #constraint(Constraint)} explicitly.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support
|
||||
CreateTableConstraintStep unique(Collection<? extends Field<?>> fields);
|
||||
|
||||
/**
|
||||
* Convenience method to add an unnamed (system named) <code>CHECK</code>
|
||||
* constraint to the table.
|
||||
|
||||
@ -68,9 +68,12 @@ import static org.jooq.impl.Keywords.K_REFERENCES;
|
||||
import static org.jooq.impl.Keywords.K_UNIQUE;
|
||||
import static org.jooq.impl.QueryPartListView.wrap;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_NAME;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.impl.Tools.fieldsByName;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_CONSTRAINT_REFERENCE;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.Clause;
|
||||
@ -333,6 +336,11 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl unique(Collection<? extends Field<?>> fields) {
|
||||
return unique(fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl check(Condition condition) {
|
||||
check = condition;
|
||||
@ -355,6 +363,11 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl primaryKey(Collection<? extends Field<?>> fields) {
|
||||
return primaryKey(fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl foreignKey(String... fields) {
|
||||
return foreignKey(fieldsByName(fields));
|
||||
@ -371,6 +384,11 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl foreignKey(Collection<? extends Field<?>> fields) {
|
||||
return foreignKey(fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl references(String table) {
|
||||
return references(table(name(table)), EMPTY_FIELD);
|
||||
@ -381,6 +399,11 @@ implements
|
||||
return references(table(name(table)), fieldsByName(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl references(String table, Collection<? extends String> fields) {
|
||||
return references(table, fields.toArray(EMPTY_STRING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl references(Name table) {
|
||||
return references(table(table), EMPTY_FIELD);
|
||||
@ -391,6 +414,11 @@ implements
|
||||
return references(table(table), fieldsByName(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl references(Name table, Collection<? extends Name> fields) {
|
||||
return references(table, fields.toArray(EMPTY_NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl references(Table table) {
|
||||
return references(table, EMPTY_FIELD);
|
||||
@ -403,6 +431,11 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl references(Table<?> table, Collection<? extends Field<?>> fields) {
|
||||
return references(table, fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ConstraintImpl onDeleteNoAction() {
|
||||
onDelete = NO_ACTION;
|
||||
|
||||
@ -309,6 +309,11 @@ final class CreateTableImpl extends AbstractDDLQuery implements
|
||||
return constraint(DSL.primaryKey(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CreateTableConstraintStep primaryKey(Collection<? extends Field<?>> fields) {
|
||||
return constraint(DSL.primaryKey(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CreateTableConstraintStep unique(String... fields) {
|
||||
return constraint(DSL.unique(fields));
|
||||
@ -324,6 +329,11 @@ final class CreateTableImpl extends AbstractDDLQuery implements
|
||||
return constraint(DSL.unique(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CreateTableConstraintStep unique(Collection<? extends Field<?>> fields) {
|
||||
return constraint(DSL.unique(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CreateTableConstraintStep check(Condition condition) {
|
||||
return constraint(DSL.check(condition));
|
||||
|
||||
@ -6414,6 +6414,15 @@ public class DSL {
|
||||
return constraint().primaryKey(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an unnamed (system named) <code>PRIMARY KEY</code> constraint.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static ConstraintEnforcementStep primaryKey(Collection<? extends Field<?>> fields) {
|
||||
return constraint().primaryKey(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a <code>FOREIGN KEY</code> clause to the <code>CONSTRAINT</code>.
|
||||
*/
|
||||
@ -6441,6 +6450,15 @@ public class DSL {
|
||||
return constraint().foreignKey(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a <code>FOREIGN KEY</code> clause to the <code>CONSTRAINT</code>.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static ConstraintForeignKeyReferencesStepN foreignKey(Collection<? extends Field<?>> fields) {
|
||||
return constraint().foreignKey(fields);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -7066,6 +7084,15 @@ public class DSL {
|
||||
return constraint().unique(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an unnamed (system named) <code>UNIQUE</code> constraint.
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
public static ConstraintEnforcementStep unique(Collection<? extends Field<?>> fields) {
|
||||
return constraint().unique(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an unnamed (system named) <code>CHECK</code> constraint.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user