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)));
}
}
}
}
Aggregations