From 95dcf6722c7d15e1243f925f2c11ffece815161f Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 1 May 2015 09:45:51 -0400 Subject: [PATCH] Have InList sql always be wrapped by parens --- .../src/main/java/com/moparisthebest/jdbc/ArrayInList.java | 6 +++--- .../java/com/moparisthebest/jdbc/OracleArrayInList.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ArrayInList.java b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ArrayInList.java index 1ddb63b..17c5a1e 100644 --- a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ArrayInList.java +++ b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/ArrayInList.java @@ -19,8 +19,8 @@ public class ArrayInList implements InList { protected ArrayInList() { } - protected String columnAppend() { - return " = ANY(?)"; + protected String columnAppend(final String columnName) { + return "(" + columnName + " = ANY(?))"; } protected Array toArray(final Connection conn, final Collection values) throws SQLException { @@ -32,7 +32,7 @@ public class ArrayInList implements InList { public InListObject inList(final Connection conn, final String columnName, final Collection values) throws SQLException { return values == null || values.isEmpty() ? InListObject.empty : new ArrayListObject( - columnName + columnAppend(), + columnAppend(columnName), toArray(conn, values) ); } diff --git a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/OracleArrayInList.java b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/OracleArrayInList.java index f78263a..542d61e 100644 --- a/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/OracleArrayInList.java +++ b/beehive-jdbc-mapper/src/main/java/com/moparisthebest/jdbc/OracleArrayInList.java @@ -37,8 +37,8 @@ public class OracleArrayInList extends ArrayInList { protected OracleArrayInList() { } - protected String columnAppend() { - return " IN(select column_value from table(?))"; + protected String columnAppend(final String columnName) { + return "(" + columnName + " IN(select column_value from table(?)))"; } protected Array toArray(final Connection conn, final Collection values) throws SQLException {