Search in sources :

Example 26 with RDB$FIELDS

use of org.jooq.meta.firebird.rdb.Tables.RDB$FIELDS in project jOOQ by jOOQ.

the class FirebirdTableDefinition method getElements0.

@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
    List<ColumnDefinition> result = new ArrayList<>();
    Rdb$relationFields r = RDB$RELATION_FIELDS.as("r");
    Rdb$fields f = RDB$FIELDS.as("f");
    // DatabaseMetaData implementation
    for (Record record : create().select(trim(r.RDB$FIELD_NAME).as(r.RDB$FIELD_NAME), r.RDB$DESCRIPTION, r.RDB$DEFAULT_VALUE, DSL.bitOr(r.RDB$NULL_FLAG.nvl(inline((short) 0)), f.RDB$NULL_FLAG.nvl(inline((short) 0))).as(r.RDB$NULL_FLAG), r.RDB$DEFAULT_SOURCE, f.RDB$COMPUTED_SOURCE, r.RDB$FIELD_POSITION, // [#3342] FIELD_LENGTH should be ignored for LOBs
    CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), trim(f.RDB$FIELD_NAME).as("DOMAIN_NAME"), r.RDB$DESCRIPTION, (((FirebirdDatabase) getDatabase()).is30() ? r.RDB$IDENTITY_TYPE : inline((short) 0)).as(r.RDB$IDENTITY_TYPE)).from(r).leftOuterJoin(f).on(r.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(r.RDB$RELATION_NAME.eq(getName())).orderBy(r.RDB$FIELD_POSITION)) {
        // [#9411] Firebird reports the DEFAULT keyword in this column, which
        // we do not want to reproduce in generated code.
        String defaultValue = record.get(r.RDB$DEFAULT_SOURCE);
        boolean computed = record.get(f.RDB$COMPUTED_SOURCE) != null;
        if (defaultValue != null)
            defaultValue = P_DEFAULT.matcher(defaultValue).replaceFirst("");
        DefaultDataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHAR_LEN", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(r.RDB$NULL_FLAG) == 0, computed ? null : defaultValue, record.get("DOMAIN_NAME") == null ? null : DSL.name(record.get("DOMAIN_NAME", String.class))).generatedAlwaysAs(computed ? record.get(f.RDB$COMPUTED_SOURCE) : null);
        result.add(new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(r.RDB$FIELD_NAME), result.size() + 1, type, record.get(r.RDB$IDENTITY_TYPE, boolean.class), record.get(r.RDB$DESCRIPTION)));
    }
    return result;
}
Also used : Rdb$relationFields(org.jooq.meta.firebird.rdb.tables.Rdb$relationFields) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) DefaultColumnDefinition(org.jooq.meta.DefaultColumnDefinition) Rdb$fields(org.jooq.meta.firebird.rdb.tables.Rdb$fields) ArrayList(java.util.ArrayList) Record(org.jooq.Record) DefaultColumnDefinition(org.jooq.meta.DefaultColumnDefinition) ColumnDefinition(org.jooq.meta.ColumnDefinition)

Aggregations

Fields (io.atlasmap.v2.Fields)15 Record (org.jooq.Record)11 Document (io.atlasmap.v2.Document)8 ArrayList (java.util.ArrayList)8 Test (org.junit.jupiter.api.Test)7 DefaultDataTypeDefinition (org.jooq.meta.DefaultDataTypeDefinition)5 Rdb$fields (org.jooq.meta.firebird.rdb.tables.Rdb$fields)5 XmlFields (io.atlasmap.xml.v2.XmlFields)4 TableDefinition (org.jooq.meta.TableDefinition)4 Rdb$relationConstraints (org.jooq.meta.firebird.rdb.tables.Rdb$relationConstraints)4 DataTypeDefinition (org.jooq.meta.DataTypeDefinition)3 SchemaDefinition (org.jooq.meta.SchemaDefinition)3 DefaultDataTypeDefinition (org.jooq.util.DefaultDataTypeDefinition)3 Rdb$fields (org.jooq.util.firebird.rdb.tables.Rdb$fields)3 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Result (org.jooq.Result)2 Rdb$functionArguments (org.jooq.meta.firebird.rdb.tables.Rdb$functionArguments)2