use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class H2RoutineDefinition method init0.
@Override
protected void init0() throws SQLException {
for (Record record : create().select(FunctionColumns.COLUMN_NAME, FunctionColumns.TYPE_NAME, FunctionColumns.PRECISION, FunctionColumns.SCALE, FunctionColumns.POS, FunctionColumns.NULLABLE, FunctionColumns.COLUMN_DEFAULT).from(FUNCTION_COLUMNS).where(FunctionColumns.ALIAS_SCHEMA.equal(getSchema().getName())).and(FunctionColumns.ALIAS_NAME.equal(getName())).and(FunctionColumns.POS.gt(0)).orderBy(FunctionColumns.POS.asc()).fetch()) {
String paramName = record.get(FunctionColumns.COLUMN_NAME);
String typeName = record.get(FunctionColumns.TYPE_NAME);
Integer precision = record.get(FunctionColumns.PRECISION);
Short scale = record.get(FunctionColumns.SCALE);
int position = record.get(FunctionColumns.POS);
boolean nullable = record.get(FunctionColumns.NULLABLE, boolean.class);
String defaultValue = record.get(FunctionColumns.COLUMN_DEFAULT);
// It is only used internally by H2 to provide a connection to the current database.
if (position == 0 && H2DataType.OTHER.getTypeName().equalsIgnoreCase(typeName)) {
continue;
}
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), typeName, precision, precision, scale, nullable, defaultValue);
ParameterDefinition parameter = new DefaultParameterDefinition(this, paramName, position, type);
addParameter(InOutDefinition.IN, parameter);
}
}
use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class H2TableDefinition method getElements0.
@Override
public List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
for (Record record : create().select(Columns.COLUMN_NAME, Columns.ORDINAL_POSITION, Columns.TYPE_NAME, Columns.CHARACTER_MAXIMUM_LENGTH, Columns.NUMERIC_PRECISION, Columns.NUMERIC_SCALE, Columns.IS_NULLABLE, Columns.COLUMN_DEFAULT, Columns.REMARKS, Columns.SEQUENCE_NAME).from(COLUMNS).where(Columns.TABLE_SCHEMA.equal(getSchema().getName())).and(Columns.TABLE_NAME.equal(getName())).orderBy(Columns.ORDINAL_POSITION).fetch()) {
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get(Columns.TYPE_NAME), record.get(Columns.CHARACTER_MAXIMUM_LENGTH), record.get(Columns.NUMERIC_PRECISION), record.get(Columns.NUMERIC_SCALE), record.get(Columns.IS_NULLABLE, boolean.class), record.get(Columns.COLUMN_DEFAULT));
ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(Columns.COLUMN_NAME), record.get(Columns.ORDINAL_POSITION), type, // [#5331] AUTO_INCREMENT (MySQL style)
null != record.get(Columns.SEQUENCE_NAME) || // [#5331] DEFAULT nextval('sequence') (PostgreSQL style)
defaultString(record.get(Columns.COLUMN_DEFAULT)).trim().toLowerCase().startsWith("nextval"), record.get(Columns.REMARKS));
result.add(column);
}
return result;
}
use of org.jooq.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class XMLDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (Sequence sequence : info().getSequences()) {
if (getInputSchemata().contains(sequence.getSequenceSchema())) {
SchemaDefinition schema = getSchema(sequence.getSequenceSchema());
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, sequence.getDataType(), sequence.getCharacterMaximumLength(), sequence.getNumericPrecision(), sequence.getNumericScale(), false, (String) null);
result.add(new DefaultSequenceDefinition(schema, sequence.getSequenceName(), type));
}
}
return result;
}
use of org.jooq.util.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 (getQualifiedNamePart().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()));
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.util.DefaultDataTypeDefinition in project jOOQ by jOOQ.
the class FirebirdRoutineDefinition method init0.
@Override
protected void init0() throws SQLException {
Rdb$procedureParameters p = RDB$PROCEDURE_PARAMETERS.as("p");
Rdb$fields f = RDB$FIELDS.as("f");
int i = 0;
for (Record record : create().select(p.RDB$PARAMETER_NUMBER, p.RDB$PARAMETER_TYPE, p.RDB$PARAMETER_NAME.trim().as(p.RDB$PARAMETER_NAME), FIELD_TYPE(f).as("FIELD_TYPE"), CHARACTER_LENGTH(f).as("CHARACTER_LENGTH"), f.RDB$FIELD_PRECISION, FIELD_SCALE(f).as("FIELD_SCALE"), DSL.bitOr(p.RDB$NULL_FLAG.nvl((short) 0), f.RDB$NULL_FLAG.nvl((short) 0)).as(p.RDB$NULL_FLAG), p.RDB$DEFAULT_SOURCE).from(p).leftOuterJoin(f).on(p.RDB$FIELD_SOURCE.eq(f.RDB$FIELD_NAME)).where(p.RDB$PROCEDURE_NAME.eq(getName())).orderBy(p.RDB$PARAMETER_TYPE.desc(), p.RDB$PARAMETER_NUMBER.asc())) {
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), record.get("FIELD_TYPE", String.class), record.get("CHARACTER_LENGTH", short.class), record.get(f.RDB$FIELD_PRECISION), record.get("FIELD_SCALE", Integer.class), record.get(p.RDB$NULL_FLAG) == 0, record.get(p.RDB$DEFAULT_SOURCE));
ParameterDefinition parameter = new DefaultParameterDefinition(this, record.get(p.RDB$PARAMETER_NAME), i++, type);
addParameter(record.get(p.RDB$PARAMETER_TYPE, int.class).equals(0) ? InOutDefinition.IN : InOutDefinition.OUT, parameter);
}
}
Aggregations