提交 f0a4ea5c authored 作者: noelgrandin's avatar noelgrandin

Issue 527: Oracle compatibility mode: incorrect scale behavior, patch by Daniel Gredler.

上级 90dfd857
...@@ -40,6 +40,7 @@ Change Log ...@@ -40,6 +40,7 @@ Change Log
</li><li>Added support for ON DUPLICATE KEY UPDATE like MySQL with the values() function to update with the value that </li><li>Added support for ON DUPLICATE KEY UPDATE like MySQL with the values() function to update with the value that
was to be inserted. Patch from Jean-Francois Noel. was to be inserted. Patch from Jean-Francois Noel.
</li><li>Issue 522: Treat empty strings like NULL in Oracle compatibility mode, patch by Daniel Gredler. </li><li>Issue 522: Treat empty strings like NULL in Oracle compatibility mode, patch by Daniel Gredler.
</li><li>Issue 527: Oracle compatibility mode: incorrect scale behavior, patch by Daniel Gredler.
</li></ul> </li></ul>
<h2>Version 1.3.174 (2013-10-19)</h2> <h2>Version 1.3.174 (2013-10-19)</h2>
......
...@@ -185,6 +185,7 @@ public class Mode { ...@@ -185,6 +185,7 @@ public class Mode {
mode = new Mode("Oracle"); mode = new Mode("Oracle");
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true;
mode.uniqueIndexSingleNullExceptAllColumnsAreNull = true; mode.uniqueIndexSingleNullExceptAllColumnsAreNull = true;
mode.treatEmptyStringsAsNull = true; mode.treatEmptyStringsAsNull = true;
add(mode); add(mode);
......
...@@ -33,6 +33,7 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -33,6 +33,7 @@ public class TestCompatibilityOracle extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
testTreatEmptyStringsAsNull(); testTreatEmptyStringsAsNull();
testDecimalScale();
} }
private void testTreatEmptyStringsAsNull() throws SQLException { private void testTreatEmptyStringsAsNull() throws SQLException {
...@@ -87,6 +88,21 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -87,6 +88,21 @@ public class TestCompatibilityOracle extends TestBase {
conn.close(); conn.close();
} }
private void testDecimalScale() throws SQLException {
deleteDb("oracle");
Connection conn = getConnection("oracle;MODE=Oracle");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE A (ID NUMBER, X DECIMAL(9,5))");
stat.execute("INSERT INTO A VALUES (1, 2)");
stat.execute("INSERT INTO A VALUES (2, 4.3)");
stat.execute("INSERT INTO A VALUES (3, '6.78')");
assertResult("3", stat, "SELECT COUNT(*) FROM A");
assertResult(new Object[][] { { 1, 2 }, { 2, 4.3 }, { 3, 6.78 } }, stat, "SELECT * FROM A");
conn.close();
}
private void assertResult(Object[][] expectedRowsOfValues, Statement stat, String sql) throws SQLException { private void assertResult(Object[][] expectedRowsOfValues, Statement stat, String sql) throws SQLException {
assertResult(newSimpleResultSet(expectedRowsOfValues), stat, sql); assertResult(newSimpleResultSet(expectedRowsOfValues), stat, sql);
} }
...@@ -117,10 +133,10 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -117,10 +133,10 @@ public class TestCompatibilityOracle extends TestBase {
return null; return null;
} }
if (object instanceof Object[]) { if (object instanceof Object[]) {
return Arrays.deepToString(((Object[]) object)); return Arrays.deepToString((Object[]) object);
} }
if (object instanceof byte[]) { if (object instanceof byte[]) {
return Arrays.toString(((byte[]) object)); return Arrays.toString((byte[]) object);
} }
return object.toString(); return object.toString();
} }
......
...@@ -743,4 +743,4 @@ lives pauses allocates kicks introduction straightforward getenv ...@@ -743,4 +743,4 @@ lives pauses allocates kicks introduction straightforward getenv
ordinate tweaking fetching rfe yates cookie btrfs cookies ordinate tweaking fetching rfe yates cookie btrfs cookies
nocycle nomaxvalue nominvalue cycling proceed prospective exhausted contingent nocycle nomaxvalue nominvalue cycling proceed prospective exhausted contingent
validities hang degenerates freezes emulation gredler cemo koc blanked validities hang degenerates freezes emulation gredler cemo koc blanked
reverting gredler blanked koc cemo jump reverting blanked jump
\ No newline at end of file \ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论