use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class XMLTableDefinition method getElements0.
@Override
protected List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<>();
for (Column column : info.getColumns()) {
if (StringUtils.equals(defaultIfNull(table.getTableCatalog(), ""), defaultIfNull(column.getTableCatalog(), "")) && StringUtils.equals(defaultIfNull(table.getTableSchema(), ""), defaultIfNull(column.getTableSchema(), "")) && StringUtils.equals(defaultIfNull(table.getTableName(), ""), defaultIfNull(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()).generatedAlwaysAs(TRUE.equals(column.isIsGenerated()) ? column.getGenerationExpression() : null).generationOption(TRUE.equals(column.isIsGenerated()) ? "STORED".equalsIgnoreCase(column.getGenerationOption()) ? STORED : "VIRTUAL".equalsIgnoreCase(column.getGenerationOption()) ? VIRTUAL : null : null);
result.add(new DefaultColumnDefinition(this, column.getColumnName(), unbox(column.getOrdinalPosition()), type, column.getIdentityGeneration() != null, TRUE.equals(column.isReadonly()), column.getComment()));
}
}
return result;
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class CUBRIDTableDefinition method getElements0.
@Override
public List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<>();
for (Record record : create().select(DB_ATTRIBUTE.ATTR_NAME, DB_ATTRIBUTE.DEF_ORDER, DB_ATTRIBUTE.DATA_TYPE, DB_ATTRIBUTE.PREC, DB_ATTRIBUTE.SCALE, DB_ATTRIBUTE.IS_NULLABLE, DB_ATTRIBUTE.DEFAULT_VALUE, DB_SERIAL.NAME).from(DB_ATTRIBUTE).leftOuterJoin(DB_SERIAL).on(DB_ATTRIBUTE.ATTR_NAME.equal(DB_SERIAL.ATT_NAME).and(DB_ATTRIBUTE.CLASS_NAME.equal(DB_SERIAL.CLASS_NAME))).where(DB_ATTRIBUTE.CLASS_NAME.equal(getName())).orderBy(DB_ATTRIBUTE.DEF_ORDER)) {
String dataType = record.get(DB_ATTRIBUTE.DATA_TYPE);
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), dataType, record.get(DB_ATTRIBUTE.PREC), record.get(DB_ATTRIBUTE.PREC), record.get(DB_ATTRIBUTE.SCALE), record.get(DB_ATTRIBUTE.IS_NULLABLE, boolean.class), record.get(DB_ATTRIBUTE.DEFAULT_VALUE), getName() + "_" + record.get(DB_ATTRIBUTE.ATTR_NAME));
result.add(new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(DB_ATTRIBUTE.ATTR_NAME), result.size() + 1, type, record.get(DB_SERIAL.NAME) != null, null));
}
return result;
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class DerbyDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<>();
for (Record record : sequences(getInputSchemata())) {
SchemaDefinition schema = getSchema(record.get(SYSSEQUENCES.sysschemas().SCHEMANAME));
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, record.get(SYSSEQUENCES.SEQUENCEDATATYPE));
result.add(new DefaultSequenceDefinition(schema, record.get(SYSSEQUENCES.SEQUENCENAME), type, null, record.get(SYSSEQUENCES.STARTVALUE), record.get(SYSSEQUENCES.INCREMENT), record.get(SYSSEQUENCES.MINIMUMVALUE), record.get(SYSSEQUENCES.MAXIMUMVALUE), record.get(SYSSEQUENCES.CYCLEOPTION, Boolean.class), null));
}
return result;
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class MariaDBDatabase method getSequences0.
@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).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, BIGINT.getTypeName());
Field<Long> startWith = nullif(field("start_value", BIGINT), inline(1L));
Field<Long> incrementBy = nullif(field("increment", BIGINT), inline(1L));
Field<Long> minValue = inline(field("minimum_value", BIGINT), inline(1L));
Field<Long> maxValue = nullif(field("maximum_value", BIGINT), inline(DEFAULT_SEQUENCE_MAXVALUE));
Field<Boolean> cycle = field("cycle_option", BOOLEAN);
Field<Long> cache = nullif(field("cache_size", BIGINT), inline(DEFAULT_SEQUENCE_CACHE));
Record flags = create().select(startWith, incrementBy, minValue, maxValue, cycle, cache).from(name(schema.getName(), name)).fetchOne();
result.add(new DefaultSequenceDefinition(schema, name, type, null, flags.get(startWith), flags.get(incrementBy), flags.get(minValue), flags.get(maxValue), flags.get(cycle), flags.get(cache)));
}
}
return result;
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class MySQLRoutineDefinition method init55.
private void init55() {
// table is available, which is much more reliable than mysql.proc
for (Record record : create().select(PARAMETERS.ORDINAL_POSITION, PARAMETERS.PARAMETER_NAME, PARAMETERS.PARAMETER_MODE, PARAMETERS.DATA_TYPE, PARAMETERS.DTD_IDENTIFIER, PARAMETERS.CHARACTER_MAXIMUM_LENGTH, PARAMETERS.NUMERIC_PRECISION, PARAMETERS.NUMERIC_SCALE).from(PARAMETERS).where(PARAMETERS.SPECIFIC_SCHEMA.in(getSchema().getInputName(), getSchema().getInputName())).and(PARAMETERS.SPECIFIC_NAME.eq(getInputName())).and(PARAMETERS.ROUTINE_TYPE.eq(procType.name())).orderBy(PARAMETERS.ORDINAL_POSITION.asc()).fetch()) {
String inOut = record.get(PARAMETERS.PARAMETER_MODE);
String dataType = record.get(PARAMETERS.DATA_TYPE);
// [#519] Some types have unsigned versions
if (getDatabase().supportsUnsignedTypes()) {
if (asList("tinyint", "smallint", "mediumint", "int", "bigint").contains(dataType.toLowerCase())) {
if (record.get(PARAMETERS.DTD_IDENTIFIER).toLowerCase().contains("unsigned")) {
dataType += "unsigned";
}
}
}
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), dataType, record.get(PARAMETERS.CHARACTER_MAXIMUM_LENGTH), record.get(PARAMETERS.NUMERIC_PRECISION), record.get(PARAMETERS.NUMERIC_SCALE), null, (String) null);
if (inOut == null) {
addParameter(InOutDefinition.RETURN, new DefaultParameterDefinition(this, "RETURN_VALUE", -1, type));
} else {
ParameterDefinition parameter = new DefaultParameterDefinition(this, record.get(PARAMETERS.PARAMETER_NAME).replaceAll("@", ""), record.get(PARAMETERS.ORDINAL_POSITION, int.class), type);
addParameter(InOutDefinition.getFromString(inOut), parameter);
}
}
}
Aggregations