提交 0ff58e70 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

Fix missing "column" type in right-hand parameter in ConditionIn. Patch by Arnaud Thimel.

上级 ddc90b86
......@@ -37,6 +37,7 @@ Change Log
</li><li>Make the planner use indexes for sorting when doing a GROUP BY where
all of the GROUP BY columns are not mentioned in the select. Patch by Frederico (zepfred).
</li><li>PostgreSQL compatibility: generate_series (as an alias for system_range). Patch by litailang.
</li><li>Fix missing "column" type in right-hand parameter in ConditionIn. Patch by Arnaud Thimel.
</li></ul>
<h2>Version 1.4.185 Beta (2015-01-16)</h2>
......
......@@ -94,6 +94,10 @@ public class ConditionIn extends Condition {
if (allValuesConstant && !e.isConstant()) {
allValuesConstant = false;
}
if (left instanceof ExpressionColumn && e instanceof Parameter) {
((Parameter) e)
.setColumn(((ExpressionColumn) left).getColumn());
}
valueList.set(i, e);
}
if (constant && allValuesConstant) {
......
......@@ -92,6 +92,8 @@ public class TestPreparedStatement extends TestBase {
testBlob(conn);
testClob(conn);
testParameterMetaData(conn);
testColumnMetaDataWithEquals(conn);
testColumnMetaDataWithIn(conn);
conn.close();
testPreparedStatementWithLiteralsNone();
deleteDb("preparedStatement");
......@@ -1023,6 +1025,7 @@ public class TestPreparedStatement extends TestBase {
prep.executeUpdate();
assertFalse(prep.getMoreResults());
assertEquals(-1, prep.getUpdateCount());
stat.execute("DROP TABLE TEST");
}
private void testObject(Connection conn) throws SQLException {
......@@ -1362,4 +1365,33 @@ public class TestPreparedStatement extends TestBase {
assertTrue(!rs.next());
}
private void testColumnMetaDataWithEquals(Connection conn)
throws SQLException {
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE TEST( id INT, someColumn INT )");
PreparedStatement ps = conn
.prepareStatement("INSERT INTO TEST VALUES(?,?)");
ps.setInt(1, 0);
ps.setInt(2, 999);
ps.execute();
ps = conn.prepareStatement("SELECT * FROM TEST WHERE someColumn = ?");
assertEquals(Types.INTEGER,
ps.getParameterMetaData().getParameterType(1));
stmt.execute("DROP TABLE TEST");
}
private void testColumnMetaDataWithIn(Connection conn) throws SQLException {
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE TEST( id INT, someColumn INT )");
PreparedStatement ps = conn
.prepareStatement("INSERT INTO TEST VALUES( ? , ? )");
ps.setInt(1, 0);
ps.setInt(2, 999);
ps.execute();
ps = conn
.prepareStatement("SELECT * FROM TEST WHERE someColumn IN (?,?)");
assertEquals(Types.INTEGER,
ps.getParameterMetaData().getParameterType(1));
stmt.execute("DROP TABLE TEST");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论