[jOOQ/jOOQ#7004] Added code generation support for MariaDB sequences
This commit is contained in:
parent
565252e9f5
commit
8a642ecd80
@ -38,10 +38,21 @@
|
||||
|
||||
package org.jooq.meta.mariadb;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.meta.DefaultDataTypeDefinition;
|
||||
import org.jooq.meta.DefaultSequenceDefinition;
|
||||
import org.jooq.meta.SchemaDefinition;
|
||||
import org.jooq.meta.SequenceDefinition;
|
||||
import org.jooq.meta.mysql.MySQLDatabase;
|
||||
import org.jooq.meta.mysql.information_schema.tables.Tables;
|
||||
import org.jooq.util.mariadb.MariaDBDataType;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -52,4 +63,30 @@ public class MariaDBDatabase extends MySQLDatabase {
|
||||
protected DSLContext create0() {
|
||||
return DSL.using(getConnection(), SQLDialect.MARIADB);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<SequenceDefinition> getSequences0() throws SQLException {
|
||||
List<SequenceDefinition> result = new ArrayList<>();
|
||||
|
||||
for (Record record : create()
|
||||
.select(Tables.TABLE_SCHEMA, Tables.TABLE_NAME)
|
||||
.from(Tables.TABLES)
|
||||
.where(Tables.TABLE_TYPE.eq("SEQUENCE"))) {
|
||||
|
||||
SchemaDefinition schema = getSchema(record.get(Tables.TABLE_SCHEMA));
|
||||
if (schema != null) {
|
||||
String name = record.get(Tables.TABLE_NAME);
|
||||
|
||||
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(
|
||||
this,
|
||||
schema,
|
||||
MariaDBDataType.BIGINT.getTypeName()
|
||||
);
|
||||
|
||||
result.add(new DefaultSequenceDefinition(schema, name, type));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user