[jOOQ/jOOQ#9590] Fixed HSQLDB, Informix, MariaDB, MySQL, SQLite
This commit is contained in:
parent
b911dfaafd
commit
9b0712cff0
@ -41,6 +41,8 @@ package org.jooq.impl;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
@ -111,6 +113,8 @@ final class MetaImpl extends AbstractMeta {
|
||||
private static final Set<SQLDialect> INVERSE_SCHEMA_CATALOG = SQLDialect.supportedBy(MARIADB, MYSQL);
|
||||
private static final Set<SQLDialect> CURRENT_TIMESTAMP_COLUMN_DEFAULT = SQLDialect.supportedBy(MARIADB, MYSQL);
|
||||
private static final Set<SQLDialect> EXPRESSION_COLUMN_DEFAULT = SQLDialect.supportedBy(H2);
|
||||
private static final Set<SQLDialect> ENCODED_TIMESTAMP_PRECISION = SQLDialect.supportedBy(HSQLDB, MARIADB);
|
||||
private static final Set<SQLDialect> NO_SUPPORT_TIMESTAMP_PRECISION = SQLDialect.supportedBy(MYSQL, SQLITE);
|
||||
|
||||
|
||||
|
||||
@ -843,7 +847,6 @@ 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
|
||||
@ -865,9 +868,11 @@ final class MetaImpl extends AbstractMeta {
|
||||
if (type.hasPrecision() && type.hasScale())
|
||||
type = type.precision(precision, scale);
|
||||
|
||||
// [#9590] Timestamp precision is in the scale column
|
||||
// [#9590] Timestamp precision is in the scale column in some dialects
|
||||
else if (type.hasPrecision() && type.isDateTime()) {
|
||||
if (nullableScale != null)
|
||||
if (ENCODED_TIMESTAMP_PRECISION.contains(dialect()))
|
||||
type = type.precision(decodeTimestampPrecision(precision));
|
||||
else if (!NO_SUPPORT_TIMESTAMP_PRECISION.contains(dialect()))
|
||||
type = type.precision(scale);
|
||||
}
|
||||
else if (type.hasPrecision())
|
||||
@ -915,6 +920,12 @@ final class MetaImpl extends AbstractMeta {
|
||||
createField(name(columnName), type, this, remarks);
|
||||
}
|
||||
}
|
||||
|
||||
private final int decodeTimestampPrecision(int precision) {
|
||||
|
||||
// [#9590] Discovered empirically from COLUMN_SIZE
|
||||
return Math.max(0, precision - 20);
|
||||
}
|
||||
}
|
||||
|
||||
private final class MetaPrimaryKey extends AbstractKey<Record> implements UniqueKey<Record> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user