Search in sources :

Example 1 with TableConstraints

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)));
        }
    }
}
Also used : TableConstraints(org.jooq.util.hsqldb.information_schema.tables.TableConstraints) SchemaDefinition(org.jooq.util.SchemaDefinition) TableDefinition(org.jooq.util.TableDefinition) Record(org.jooq.Record) DefaultCheckConstraintDefinition(org.jooq.util.DefaultCheckConstraintDefinition) CheckConstraints(org.jooq.util.hsqldb.information_schema.tables.CheckConstraints)

Aggregations

Record (org.jooq.Record)1 DefaultCheckConstraintDefinition (org.jooq.util.DefaultCheckConstraintDefinition)1 SchemaDefinition (org.jooq.util.SchemaDefinition)1 TableDefinition (org.jooq.util.TableDefinition)1 CheckConstraints (org.jooq.util.hsqldb.information_schema.tables.CheckConstraints)1 TableConstraints (org.jooq.util.hsqldb.information_schema.tables.TableConstraints)1