use of org.jooq.util.hsqldb.information_schema.tables.TableConstraints in project jOOQ by jOOQ.
the class HSQLDBDatabase method loadCheckConstraints.
@Override
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
TableConstraints tc = TABLE_CONSTRAINTS.as("tc");
CheckConstraints cc = CHECK_CONSTRAINTS.as("cc");
// [#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(tc.TABLE_SCHEMA, tc.TABLE_NAME, constraintName, cc.CHECK_CLAUSE).from(tc).join(cc).using(tc.CONSTRAINT_CATALOG, tc.CONSTRAINT_SCHEMA, tc.CONSTRAINT_NAME).where(tc.TABLE_SCHEMA.in(getInputSchemata())).fetch()) {
SchemaDefinition schema = getSchema(record.get(tc.TABLE_SCHEMA));
TableDefinition table = getTable(schema, record.get(tc.TABLE_NAME));
if (table != null) {
relations.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, record.get(constraintName), record.get(cc.CHECK_CLAUSE)));
}
}
}
Aggregations