Search in sources :

Example 26 with DefaultDataTypeDefinition

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;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record)

Example 27 with DefaultDataTypeDefinition

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;
}
Also used : DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) DefaultSequenceDefinition(org.jooq.util.DefaultSequenceDefinition) SequenceDefinition(org.jooq.util.SequenceDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DataTypeDefinition(org.jooq.util.DataTypeDefinition)

Example 28 with DefaultDataTypeDefinition

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;
}
Also used : DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition) ArrayList(java.util.ArrayList) Record(org.jooq.Record) ColumnDefinition(org.jooq.util.ColumnDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition)

Example 29 with DefaultDataTypeDefinition

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;
}
Also used : SchemaDefinition(org.jooq.util.SchemaDefinition) Column(org.jooq.util.xml.jaxb.Column) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition) ArrayList(java.util.ArrayList) DataTypeDefinition(org.jooq.util.DataTypeDefinition) DefaultDataTypeDefinition(org.jooq.util.DefaultDataTypeDefinition) ColumnDefinition(org.jooq.util.ColumnDefinition) DefaultColumnDefinition(org.jooq.util.DefaultColumnDefinition)

Aggregations

DefaultDataTypeDefinition (org.jooq.util.DefaultDataTypeDefinition)29 DataTypeDefinition (org.jooq.util.DataTypeDefinition)25 ArrayList (java.util.ArrayList)22 Record (org.jooq.Record)22 SchemaDefinition (org.jooq.util.SchemaDefinition)14 ColumnDefinition (org.jooq.util.ColumnDefinition)13 DefaultColumnDefinition (org.jooq.util.DefaultColumnDefinition)13 DefaultParameterDefinition (org.jooq.util.DefaultParameterDefinition)7 DefaultSequenceDefinition (org.jooq.util.DefaultSequenceDefinition)7 SequenceDefinition (org.jooq.util.SequenceDefinition)7 ParameterDefinition (org.jooq.util.ParameterDefinition)6 StringUtils.defaultString (org.jooq.tools.StringUtils.defaultString)3 Rdb$fields (org.jooq.util.firebird.rdb.tables.Rdb$fields)3 PgNamespace (org.jooq.util.postgres.pg_catalog.tables.PgNamespace)3 Rdb$procedureParameters (org.jooq.util.firebird.rdb.tables.Rdb$procedureParameters)2 Columns (org.jooq.util.postgres.information_schema.tables.Columns)2 PgType (org.jooq.util.postgres.pg_catalog.tables.PgType)2 Name (org.jooq.Name)1 Schema (org.jooq.Schema)1 AttributeDefinition (org.jooq.util.AttributeDefinition)1