use of org.jooq.util.DataTypeDefinition in project jOOQ by jOOQ.
the class MySQLRoutineDefinition method createParameter.
private ParameterDefinition createParameter(Matcher matcher, int group, int columnIndex, String paramName) {
String paramType = matcher.group(group + 1);
Number precision = 0;
Number scale = 0;
if (!StringUtils.isBlank(matcher.group(group + 2))) {
precision = Integer.valueOf(matcher.group(group + 2));
}
if (!StringUtils.isBlank(matcher.group(group + 3))) {
scale = Integer.valueOf(matcher.group(group + 3));
}
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), paramType, precision, precision, scale, null, (String) null);
return new DefaultParameterDefinition(this, paramName, columnIndex, type);
}
use of org.jooq.util.DataTypeDefinition in project jOOQ by jOOQ.
the class MySQLTableDefinition method getElements0.
@Override
public List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
for (Record record : create().select(Columns.ORDINAL_POSITION, Columns.COLUMN_NAME, Columns.COLUMN_COMMENT, Columns.COLUMN_TYPE, Columns.DATA_TYPE, Columns.IS_NULLABLE, Columns.COLUMN_DEFAULT, Columns.CHARACTER_MAXIMUM_LENGTH, Columns.NUMERIC_PRECISION, Columns.NUMERIC_SCALE, Columns.EXTRA).from(COLUMNS).where(TABLE_SCHEMA.equal(getSchema().getName())).and(TABLE_NAME.equal(getName())).orderBy(ORDINAL_POSITION)) {
String dataType = record.get(Columns.DATA_TYPE);
// [#519] Some types have unsigned versions
if (getDatabase().supportsUnsignedTypes()) {
if (asList("tinyint", "smallint", "mediumint", "int", "bigint").contains(dataType.toLowerCase())) {
if (record.get(Columns.COLUMN_TYPE).toLowerCase().contains("unsigned")) {
dataType += "unsigned";
}
}
}
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), dataType, 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), name(getSchema().getName(), getName() + "_" + record.get(Columns.COLUMN_NAME)));
ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(Columns.COLUMN_NAME), record.get(Columns.ORDINAL_POSITION, int.class), type, "auto_increment".equalsIgnoreCase(record.get(Columns.EXTRA)), record.get(Columns.COLUMN_COMMENT));
result.add(column);
}
return result;
}
use of org.jooq.util.DataTypeDefinition in project jOOQ by jOOQ.
the class DerbyTableDefinition method getElements0.
@Override
public List<ColumnDefinition> getElements0() throws SQLException {
List<ColumnDefinition> result = new ArrayList<ColumnDefinition>();
for (Record record : create().select(Syscolumns.COLUMNNAME, Syscolumns.COLUMNNUMBER, Syscolumns.COLUMNDATATYPE, Syscolumns.COLUMNDEFAULT, Syscolumns.AUTOINCREMENTINC).from(SYSCOLUMNS).where(Syscolumns.REFERENCEID.equal(inline(tableid))).orderBy(Syscolumns.COLUMNNUMBER).fetch()) {
String typeName = record.get(Syscolumns.COLUMNDATATYPE, String.class);
Number precision = parsePrecision(typeName);
Number scale = parseScale(typeName);
DataTypeDefinition type = new DefaultDataTypeDefinition(getDatabase(), getSchema(), parseTypeName(typeName), precision, precision, scale, !parseNotNull(typeName), record.get(Syscolumns.COLUMNDEFAULT));
ColumnDefinition column = new DefaultColumnDefinition(getDatabase().getTable(getSchema(), getName()), record.get(Syscolumns.COLUMNNAME), record.get(Syscolumns.COLUMNNUMBER), type, null != record.get(Syscolumns.AUTOINCREMENTINC), null);
result.add(column);
}
return result;
}
use of org.jooq.util.DataTypeDefinition in project jOOQ by jOOQ.
the class FirebirdDatabase method getSequences0.
@Override
protected List<SequenceDefinition> getSequences0() throws SQLException {
List<SequenceDefinition> result = new ArrayList<SequenceDefinition>();
for (String sequenceName : create().select(RDB$GENERATORS.RDB$GENERATOR_NAME.trim()).from(RDB$GENERATORS).orderBy(1).fetch(RDB$GENERATORS.RDB$GENERATOR_NAME.trim())) {
SchemaDefinition schema = getSchemata().get(0);
DataTypeDefinition type = new DefaultDataTypeDefinition(this, schema, FirebirdDataType.BIGINT.getTypeName());
result.add(new DefaultSequenceDefinition(schema, sequenceName, type));
}
return result;
}
use of org.jooq.util.DataTypeDefinition 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;
}
Aggregations