提交 d4d2b4da authored 作者: Thomas Mueller's avatar Thomas Mueller

Linked tables: for DECIMAL column, Oracle reports precision 0 and scale -127. A…

Linked tables: for DECIMAL column, Oracle reports precision 0 and scale -127. A workaround has been implemented.
上级 df440fa7
...@@ -133,6 +133,7 @@ public class TableLink extends Table { ...@@ -133,6 +133,7 @@ public class TableLink extends Table {
long precision = rs.getInt("COLUMN_SIZE"); long precision = rs.getInt("COLUMN_SIZE");
precision = convertPrecision(sqlType, precision); precision = convertPrecision(sqlType, precision);
int scale = rs.getInt("DECIMAL_DIGITS"); int scale = rs.getInt("DECIMAL_DIGITS");
scale = convertScale(sqlType, scale);
int displaySize = MathUtils.convertLongToInt(precision); int displaySize = MathUtils.convertLongToInt(precision);
int type = DataType.convertSQLTypeToValueType(sqlType); int type = DataType.convertSQLTypeToValueType(sqlType);
Column col = new Column(n, type, precision, scale, displaySize); Column col = new Column(n, type, precision, scale, displaySize);
...@@ -259,9 +260,15 @@ public class TableLink extends Table { ...@@ -259,9 +260,15 @@ public class TableLink extends Table {
} }
private long convertPrecision(int sqlType, long precision) { private long convertPrecision(int sqlType, long precision) {
// workaround for an Oracle problem // workaround for an Oracle problem:
// the precision reported by Oracle is 7 for a date column // for DATE columns, the reported precision is 7
// for DECIMAL columns, the reported precision is 0
switch (sqlType) { switch (sqlType) {
case Types.DECIMAL:
if (precision == 0) {
precision = 65535;
}
break;
case Types.DATE: case Types.DATE:
precision = Math.max(ValueDate.PRECISION, precision); precision = Math.max(ValueDate.PRECISION, precision);
break; break;
...@@ -275,6 +282,19 @@ public class TableLink extends Table { ...@@ -275,6 +282,19 @@ public class TableLink extends Table {
return precision; return precision;
} }
private int convertScale(int sqlType, int scale) {
// workaround for an Oracle problem:
// for DECIMAL columns, the reported precision is -127
switch (sqlType) {
case Types.DECIMAL:
if (scale < 0) {
scale = 32767;
}
break;
}
return scale;
}
private String convertColumnName(String columnName) { private String convertColumnName(String columnName) {
if ((storesMixedCase || storesLowerCase) && columnName.equals(StringUtils.toLowerEnglish(columnName))) { if ((storesMixedCase || storesLowerCase) && columnName.equals(StringUtils.toLowerEnglish(columnName))) {
columnName = StringUtils.toUpperEnglish(columnName); columnName = StringUtils.toUpperEnglish(columnName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论