use of org.jooq.meta.hsqldb.information_schema.tables.CheckConstraints in project jOOQ by jOOQ.
the class H2Database method loadCheckConstraints2_0.
private void loadCheckConstraints2_0(DefaultRelations relations) {
CheckConstraints cc = CHECK_CONSTRAINTS.as("cc");
for (Record record : create().select(cc.tableConstraints().TABLE_SCHEMA, cc.tableConstraints().TABLE_NAME, cc.CONSTRAINT_NAME, cc.CHECK_CLAUSE).from(cc).where(cc.tableConstraints().TABLE_SCHEMA.in(getInputSchemata()))) {
SchemaDefinition schema = getSchema(record.get(cc.tableConstraints().TABLE_SCHEMA));
TableDefinition table = getTable(schema, record.get(cc.tableConstraints().TABLE_NAME));
if (table != null) {
relations.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, record.get(cc.CONSTRAINT_NAME), record.get(cc.CHECK_CLAUSE)));
}
}
}
use of org.jooq.meta.hsqldb.information_schema.tables.CheckConstraints in project jOOQ by jOOQ.
the class HSQLDBDatabase method loadCheckConstraints.
@Override
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
CheckConstraints cc = CHECK_CONSTRAINTS.as("cc");
Columns c = COLUMNS.as("c");
// [#2808] [#3019] Workaround for bad handling of JOIN .. USING
Field<String> constraintName = field(name(cc.CONSTRAINT_NAME.getName()), String.class);
for (Record record : create().select(cc.tableConstraints().TABLE_SCHEMA, cc.tableConstraints().TABLE_NAME, constraintName, cc.CHECK_CLAUSE).from(cc).where(cc.tableConstraints().TABLE_SCHEMA.in(getInputSchemata())).and(getIncludeSystemCheckConstraints() ? noCondition() : cc.tableConstraints().CONSTRAINT_NAME.notLike("SYS!_CT!_%", '!').or(cc.CHECK_CLAUSE.notIn(// TODO: Should we ever quote these?
select(c.TABLE_SCHEMA.concat(inline('.')).concat(c.TABLE_NAME).concat(inline('.')).concat(c.COLUMN_NAME).concat(inline(" IS NOT NULL"))).from(c).where(c.TABLE_SCHEMA.eq(cc.tableConstraints().TABLE_SCHEMA)).and(c.TABLE_NAME.eq(cc.tableConstraints().TABLE_NAME)))))) {
SchemaDefinition schema = getSchema(record.get(cc.tableConstraints().TABLE_SCHEMA));
TableDefinition table = getTable(schema, record.get(cc.tableConstraints().TABLE_NAME));
if (table != null) {
relations.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, record.get(constraintName), record.get(cc.CHECK_CLAUSE)));
}
}
}
Aggregations