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

Small improvements.

上级 dec7fdf7
...@@ -586,8 +586,9 @@ public class DataType { ...@@ -586,8 +586,9 @@ public class DataType {
if (list == null) { if (list == null) {
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
} }
Value[] values = new Value[list.length]; int len = list.length;
for (int i = 0; i < list.length; i++) { Value[] values = new Value[len];
for (int i = 0; i < len; i++) {
values[i] = DataType.convertToValue(session, list[i], Value.NULL); values[i] = DataType.convertToValue(session, list[i], Value.NULL);
} }
v = ValueArray.get(values); v = ValueArray.get(values);
......
...@@ -802,8 +802,10 @@ public abstract class Value { ...@@ -802,8 +802,10 @@ public abstract class Value {
* 1 otherwise * 1 otherwise
*/ */
public final int compareTypeSave(Value v, CompareMode mode) { public final int compareTypeSave(Value v, CompareMode mode) {
if (this == ValueNull.INSTANCE) { if (this == v) {
return v == ValueNull.INSTANCE ? 0 : -1; return 0;
} else if (this == ValueNull.INSTANCE) {
return -1;
} else if (v == ValueNull.INSTANCE) { } else if (v == ValueNull.INSTANCE) {
return 1; return 1;
} }
......
...@@ -86,8 +86,9 @@ public class ValueArray extends Value { ...@@ -86,8 +86,9 @@ public class ValueArray extends Value {
} }
public Object getObject() { public Object getObject() {
Object[] list = new Object[values.length]; int len = values.length;
for (int i = 0; i < values.length; i++) { Object[] list = new Object[len];
for (int i = 0; i < len; i++) {
list[i] = values[i].getObject(); list[i] = values[i].getObject();
} }
return list; return list;
...@@ -131,10 +132,11 @@ public class ValueArray extends Value { ...@@ -131,10 +132,11 @@ public class ValueArray extends Value {
if (values == v.values) { if (values == v.values) {
return true; return true;
} }
if (values.length != v.values.length) { int len = values.length;
if (len != v.values.length) {
return false; return false;
} }
for (int i = 0; i < values.length; i++) { for (int i = 0; i < len; i++) {
if (!values[i].equals(v.values[i])) { if (!values[i].equals(v.values[i])) {
return false; return false;
} }
......
...@@ -60,8 +60,8 @@ public class TestCallableStatement extends TestBase { ...@@ -60,8 +60,8 @@ public class TestCallableStatement extends TestBase {
assertEquals(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
assertEquals("Hello", rs.getString(2)); assertEquals("Hello", rs.getString(2));
assertFalse(rs.next()); assertFalse(rs.next());
stat.execute("CREATE ALIAS testcall FOR \"" + getClass().getName() + ".testCall\""); stat.execute("CREATE ALIAS testCall FOR \"" + getClass().getName() + ".testCall\"");
call = conn.prepareCall("{CALL testcall(?,?,?)}"); call = conn.prepareCall("{CALL testCall(?,?,?)}");
call.setInt("A", 100); call.setInt("A", 100);
call.setString(2, "abc"); call.setString(2, "abc");
long t = System.currentTimeMillis(); long t = System.currentTimeMillis();
...@@ -93,7 +93,7 @@ public class TestCallableStatement extends TestBase { ...@@ -93,7 +93,7 @@ public class TestCallableStatement extends TestBase {
// expected exception // expected exception
} }
try { try {
call.getBoolean("ASD"); call.getBoolean("X");
fail("incorrect parameter name value"); fail("incorrect parameter name value");
} catch (SQLException e) { } catch (SQLException e) {
// expected exception // expected exception
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论