use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class H2Database method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (Record record : create().select(Sequences.SEQUENCE_SCHEMA, Sequences.SEQUENCE_NAME).from(SEQUENCES).where(Sequences.SEQUENCE_SCHEMA.in(getInputSchemata())).orderBy(Sequences.SEQUENCE_SCHEMA, Sequences.SEQUENCE_NAME).fetch()) {
SchemaDefinition schema = getSchema(record.get(Sequences.SEQUENCE_SCHEMA));
if (schema != null) {
String name = record.get(Sequences.SEQUENCE_NAME);
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, H2DataType.BIGINT.getTypeName());
result.add(new DefaultSequenceDefinition(schema, name, type));
}
}
return result;
}
use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class HSQLDBDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (Record record : create().select(SEQUENCES.SEQUENCE_SCHEMA, SEQUENCES.SEQUENCE_NAME, SEQUENCES.DATA_TYPE).from(SEQUENCES).where(SEQUENCES.SEQUENCE_SCHEMA.in(getInputSchemata())).orderBy(SEQUENCES.SEQUENCE_SCHEMA, SEQUENCES.SEQUENCE_NAME).fetch()) {
SchemaDefinition schema = getSchema(record.get(SEQUENCES.SEQUENCE_SCHEMA));
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, record.get(SEQUENCES.DATA_TYPE));
result.add(new DefaultSequenceDefinition(schema, record.get(SEQUENCES.SEQUENCE_NAME), type));
}
return result;
}
use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class SQLiteTableDefinition method getElements0.
@Override
public List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
int position = 0;
for (Record record : create().fetch("pragma table_info('" + getName() + "')")) {
position++;
String name = record.get("name", String.class);
String dataType = record.get("type", String.class).replaceAll("\\(\\d+(\\s*,\\s*\\d+)?\\)", "");
Number precision = parsePrecision(record.get("type", String.class));
Number scale = parseScale(record.get("type", String.class));
// SQLite identities are primary keys whose tables are mentioned in
// sqlite_sequence
int pk = record.get("pk", int.class);
boolean identity = pk > 0 && existsSqliteSequence() && create().fetchOne("select count(*) from sqlite_sequence where name = ?", getName()).get(0, Boolean.class);
DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), dataType, precision, precision, scale, !record.get("notnull", boolean.class), record.get("dflt_value", String.class));
ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), name, position, type, identity, null);
result.add(column);
}
return result;
}
use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class XMLTableDefinition method getElements0.
@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
for (Column column : info.getColumns()) {
if (StringUtils.equals(table.getTableCatalog(), column.getTableCatalog()) && StringUtils.equals(table.getTableSchema(), column.getTableSchema()) && StringUtils.equals(table.getTableName(), column.getTableName())) {
SchemaDefinition schema = getDatabase().getSchema(column.getTableSchema());
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), schema, column.getDataType(), unbox(column.getCharacterMaximumLength()), unbox(column.getNumericPrecision()), unbox(column.getNumericScale()), column.isIsNullable(), column.getColumnDefault());
result.add(new DefaultColumnDefinition(this, column.getColumnName(), unbox(column.getOrdinalPosition()), type, column.getIdentityGeneration() != null, ""));
}
}
return result;
}
Aggregations