Search in sources :

Example 1 with MariaDBDatabase

use of org.jooq.meta.mariadb.MariaDBDatabase in project jOOQ by jOOQ.

the class MySQLDatabase method loadCheckConstraints.

@Override
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
    if (is8_0_16()) {
        for (Record record : create().select(TABLE_CONSTRAINTS.TABLE_SCHEMA, TABLE_CONSTRAINTS.TABLE_NAME, CHECK_CONSTRAINTS.CONSTRAINT_NAME, CHECK_CONSTRAINTS.CHECK_CLAUSE, // https://jira.mariadb.org/browse/MDEV-21201
        TABLE_CONSTRAINTS.CONSTRAINT_CATALOG, TABLE_CONSTRAINTS.CONSTRAINT_SCHEMA).from(TABLE_CONSTRAINTS).join(CHECK_CONSTRAINTS).using(this instanceof MariaDBDatabase ? new Field[] { TABLE_CONSTRAINTS.CONSTRAINT_CATALOG, TABLE_CONSTRAINTS.CONSTRAINT_SCHEMA, // MariaDB has this column, but not MySQL
        TABLE_CONSTRAINTS.TABLE_NAME, TABLE_CONSTRAINTS.CONSTRAINT_NAME } : new Field[] { TABLE_CONSTRAINTS.CONSTRAINT_CATALOG, TABLE_CONSTRAINTS.CONSTRAINT_SCHEMA, TABLE_CONSTRAINTS.CONSTRAINT_NAME }).where(TABLE_CONSTRAINTS.TABLE_SCHEMA.in(getInputSchemata())).orderBy(TABLE_CONSTRAINTS.TABLE_SCHEMA, TABLE_CONSTRAINTS.TABLE_NAME, TABLE_CONSTRAINTS.CONSTRAINT_NAME)) {
            SchemaDefinition schema = getSchema(record.get(TABLE_CONSTRAINTS.TABLE_SCHEMA));
            TableDefinition table = getTable(schema, record.get(TABLE_CONSTRAINTS.TABLE_NAME));
            if (table != null) {
                relations.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, record.get(CHECK_CONSTRAINTS.CONSTRAINT_NAME), record.get(CHECK_CONSTRAINTS.CHECK_CLAUSE)));
            }
        }
    }
}
Also used : MariaDBDatabase(org.jooq.meta.mariadb.MariaDBDatabase) Field(org.jooq.Field) TableField(org.jooq.TableField) SchemaDefinition(org.jooq.meta.SchemaDefinition) TableDefinition(org.jooq.meta.TableDefinition) Record(org.jooq.Record) DefaultCheckConstraintDefinition(org.jooq.meta.DefaultCheckConstraintDefinition)

Aggregations

Field (org.jooq.Field)1 Record (org.jooq.Record)1 TableField (org.jooq.TableField)1 DefaultCheckConstraintDefinition (org.jooq.meta.DefaultCheckConstraintDefinition)1 SchemaDefinition (org.jooq.meta.SchemaDefinition)1 TableDefinition (org.jooq.meta.TableDefinition)1 MariaDBDatabase (org.jooq.meta.mariadb.MariaDBDatabase)1