[#456] Add runtime support for PRECISION, SCALE, and LENGTH attributes -

Added support for precision, scale, and length information in
org.jooq.Meta
This commit is contained in:
Lukas Eder 2012-12-21 22:40:18 +01:00
parent fa26d287bf
commit 1161afbad1

View File

@ -48,7 +48,6 @@ import org.jooq.ForeignKey;
import org.jooq.Meta;
import org.jooq.Record;
import org.jooq.Result;
import org.jooq.SQLDialect;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
@ -209,7 +208,6 @@ class MetaImpl implements Meta {
init();
}
@SuppressWarnings("deprecation")
private final void init() {
try {
Result<Record> columns = executor.fetch(meta().getColumns(null, getSchema().getName(), getName(), "%"));
@ -223,7 +221,19 @@ class MetaImpl implements Meta {
// TODO: Exception handling should be moved inside SQLDataType
DataType<?> type = null;
try {
type = DefaultDataType.getDataType(SQLDialect.SQL99, typeName, precision, scale);
type = DefaultDataType.getDataType(executor.getDialect(), typeName, precision, scale);
if (type.hasPrecision()) {
type = type.precision(precision);
}
if (type.hasScale()) {
type = type.scale(scale);
}
if (type.hasLength()) {
// JDBC doesn't distinguish between precision and length
type = type.length(precision);
}
}
catch (SQLDialectNotSupportedException e) {
type = SQLDataType.OTHER;