use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class XMLRoutineDefinition method init0.
@Override
protected void init0() {
for (Parameter parameter : info.getParameters()) {
Name parameterRoutineName = name(parameter.getSpecificCatalog(), parameter.getSpecificSchema(), parameter.getSpecificPackage(), parameter.getSpecificName());
if (specificName.equals(parameterRoutineName)) {
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), parameter.getDataType(), parameter.getCharacterMaximumLength(), parameter.getNumericPrecision(), parameter.getNumericScale(), null, parameter.getParameterDefault());
ParameterDefinition p = new DefaultParameterDefinition(this, parameter.getParameterName(), parameter.getOrdinalPosition(), type, !StringUtils.isBlank(parameter.getParameterDefault()), StringUtils.isBlank(parameter.getParameterName()), parameter.getComment());
switch(parameter.getParameterMode()) {
case IN:
addParameter(InOutDefinition.IN, p);
break;
case INOUT:
addParameter(InOutDefinition.INOUT, p);
break;
case OUT:
addParameter(InOutDefinition.OUT, p);
break;
}
}
}
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class FirebirdDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<>();
for (Record record : sequences(getInputSchemata())) {
SchemaDefinition schema = getSchemata().get(0);
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, FirebirdDataType.BIGINT.getTypeName());
result.add(new DefaultSequenceDefinition(schema, record.get(RDB$GENERATORS.RDB$GENERATOR_NAME), type, null, record.get(RDB$GENERATORS.RDB$INITIAL_VALUE), record.get(RDB$GENERATORS.RDB$GENERATOR_INCREMENT), null, null, false, null));
}
return result;
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class FirebirdDatabase method getDomains0.
@Override
protected List<DomainDefinition> getDomains0() throws SQLException {
List<DomainDefinition> result = new ArrayList<>();
Rdb$fields f = RDB$FIELDS;
for (Record record : create().select(trim(f.RDB$FIELD_NAME).as(f.RDB$FIELD_NAME), CHARACTER_LENGTH(f).as("CHAR_LEN"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), FIELD_TYPE(f).as("FIELD_TYPE"), DSL.bitOr(f.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(f.RDB$NULL_FLAG), trim(f.RDB$VALIDATION_SOURCE).as(f.RDB$VALIDATION_SOURCE), trim(f.RDB$DEFAULT_SOURCE).as(f.RDB$DEFAULT_SOURCE)).from(f).where(f.RDB$FIELD_NAME.notLike(any("RDB$%", "SEC$%", "MON$%"))).orderBy(f.RDB$FIELD_NAME)) {
SchemaDefinition schema = getSchemata().get(0);
DataTypeDefinition baseType = new DefaultDataTypeDefinition(this, schema, 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(f.RDB$NULL_FLAG) == 0, record.get(f.RDB$DEFAULT_SOURCE) == null ? null : record.get(f.RDB$DEFAULT_SOURCE).replaceAll("(?i:default )", ""));
DefaultDomainDefinition domain = new DefaultDomainDefinition(schema, record.get(f.RDB$FIELD_NAME), baseType);
if (!StringUtils.isBlank(record.get(f.RDB$VALIDATION_SOURCE)))
domain.addCheckClause(record.get(f.RDB$VALIDATION_SOURCE).replaceAll("(?i:check )", ""));
result.add(domain);
}
return result;
}
use of org.jooq.meta.DefaultDataTypeDefinition 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;
}
use of org.jooq.meta.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class DerbyTableDefinition method getElements0.
@Override
public List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<>();
for (Record record : create().select(SYSCOLUMNS.COLUMNNAME, SYSCOLUMNS.COLUMNNUMBER, SYSCOLUMNS.COLUMNDATATYPE, when(SYSCOLUMNS.AUTOINCREMENTINC.isNull(), SYSCOLUMNS.COLUMNDEFAULT).as(SYSCOLUMNS.COLUMNDEFAULT), SYSCOLUMNS.AUTOINCREMENTINC).from(SYSCOLUMNS).where(SYSCOLUMNS.REFERENCEID.cast(VARCHAR(32672)).equal(inline(tableid))).orderBy(SYSCOLUMNS.COLUMNNUMBER)) {
String columnDataType = record.get(SYSCOLUMNS.COLUMNDATATYPE, String.class);
String typeName = parseTypeName(columnDataType);
// [#9945] Derby timestamps always have a precision of 9
Number precision = "TIMESTAMP".equalsIgnoreCase(typeName) ? 9 : parsePrecision(columnDataType);
Number scale = parseScale(columnDataType);
String defaultValue = record.get(SYSCOLUMNS.COLUMNDEFAULT);
boolean generated = defaultValue != null && defaultValue.toUpperCase().startsWith("GENERATED ALWAYS AS");
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), typeName, precision, precision, scale, !parseNotNull(columnDataType), generated ? null : defaultValue).generatedAlwaysAs(generated ? defaultValue.replaceAll("(?i:GENERATED\\s+ALWAYS\\s+AS\\s*\\(\\s*(.*?)\\s*\\)\\s*)", "$1") : null);
result.add(new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(SYSCOLUMNS.COLUMNNAME), result.size() + 1, type, null != record.get(SYSCOLUMNS.AUTOINCREMENTINC), null));
}
return result;
}
Aggregations