You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/06/15 16:10:04 UTC

groovy git commit: GROOVY-8174: Groovy.Sql+Oracle parameter substitution problem (log instead of throwing exception since current drivers aren't consistent enough)

Repository: groovy
Updated Branches:
  refs/heads/master 0406787a5 -> e4935157a


GROOVY-8174: Groovy.Sql+Oracle parameter substitution problem (log instead of throwing exception since current drivers aren't consistent enough)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e4935157
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e4935157
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e4935157

Branch: refs/heads/master
Commit: e4935157a6264156094ec3bafa3ba869a36006dd
Parents: 0406787
Author: paulk <pa...@asert.com.au>
Authored: Fri Jun 16 02:09:35 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Jun 16 02:09:35 2017 +1000

----------------------------------------------------------------------
 subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java |  5 ++---
 .../src/test/groovy/groovy/sql/SqlCompleteTest.groovy    | 11 ++++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e4935157/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
index 87b3df6..1eb6ccc 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -4150,9 +4150,8 @@ public class Sql {
                 Map paramsMap = (Map) params.get(0);
                 if (paramsMap.isEmpty()) return;
             }
-            if (metaData.getParameterCount() < params.size()) {
-                throw new IllegalArgumentException("Found " + metaData.getParameterCount() + " parameter placeholders but supplied with " + params.size() + " parameters");
-            } else if (metaData.getParameterCount() != params.size()) {
+            // GROOVY-8174: we'd like stricter checking here but many drivers currently in use just aren't consistent enough, so we log
+            if (metaData.getParameterCount() != params.size()) {
                 LOG.warning("Found " + metaData.getParameterCount() + " parameter placeholders but supplied with " + params.size() + " parameters");
             }
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/e4935157/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlCompleteTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlCompleteTest.groovy b/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlCompleteTest.groovy
index 7ee8705..ad399d9 100644
--- a/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlCompleteTest.groovy
+++ b/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlCompleteTest.groovy
@@ -146,11 +146,12 @@ class SqlCompleteTest extends SqlHelperTestCase {
         assert results.collectEntries{ [it.firstname, it.lastname] } == ["James": "Strachan", "Sam": "Pullara"]
     }
 
-    void testRowsWithIncorrectNumberOfParams() {
-        shouldFail(IllegalArgumentException) {
-            sql.rows("select * from PERSON where firstname like ? and lastname like ?", ['foo', 'bar', 'baz'])
-        }
-    }
+    // GROOVY-8174: we'd like a strict test like this but current drivers aren't up to it
+//    void testRowsWithIncorrectNumberOfParams() {
+//        shouldFail(IllegalArgumentException) {
+//            sql.rows("select * from PERSON where firstname like ? and lastname like ?", ['foo', 'bar', 'baz'])
+//        }
+//    }
 
     void testRowsWithIncorrectParam() {
         shouldFail(IllegalArgumentException) {