[jOOQ/jOOQ#9590] JDBC DatabaseMetaData backed Meta implementation should read DECIMAL_DIGITS for timestamp precision, not COLUMN_SIZE

This commit is contained in:
Lukas Eder 2020-07-08 16:53:53 +02:00
parent 0f576cc931
commit 9eae07174c

View File

@ -843,6 +843,7 @@ final class MetaImpl extends AbstractMeta {
String typeName = column.get(5, String.class); // TYPE_NAME
int precision = column.get(6, int.class); // COLUMN_SIZE
int scale = column.get(8, int.class); // DECIMAL_DIGITS
Integer nullableScale = column.get(8, Integer.class); // DECIMAL_DIGITS
int nullable = column.get(10, int.class); // NULLABLE
String remarks = column.get(11, String.class); // REMARKS
String defaultValue = column.get(12, String.class); // COLUMN_DEF
@ -863,8 +864,15 @@ final class MetaImpl extends AbstractMeta {
// JDBC doesn't distinguish between precision and length
if (type.hasPrecision() && type.hasScale())
type = type.precision(precision, scale);
// [#9590] Timestamp precision is in the scale column
else if (type.hasPrecision() && type.isDateTime()) {
if (nullableScale != null)
type = type.precision(scale);
}
else if (type.hasPrecision())
type = type.precision(precision);
else if (type.hasLength())
type = type.length(precision);