Search in sources :

Example 1 with TableConstraints

use of org.jooq.util.postgres.information_schema.tables.TableConstraints in project jOOQ by jOOQ.

the class PostgresDatabase method loadCheckConstraints.

@Override
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
    TableConstraints tc = TABLE_CONSTRAINTS.as("tc");
    CheckConstraints cc = CHECK_CONSTRAINTS.as("cc");
    for (Record record : create().select(tc.TABLE_SCHEMA, tc.TABLE_NAME, cc.CONSTRAINT_NAME, 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(cc.CONSTRAINT_NAME), record.get(cc.CHECK_CLAUSE)));
        }
    }
}
Also used : TableConstraints(org.jooq.util.postgres.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.postgres.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.postgres.information_schema.tables.CheckConstraints)1 TableConstraints (org.jooq.util.postgres.information_schema.tables.TableConstraints)1