groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: GROOVY-8174: Groovy.Sql+Oracle parameter substitution problem (log instead of throwing exception since current drivers aren't consistent enough)
Date Thu, 15 Jun 2017 16:11:24 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X f033336a9 -> 47581506d


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/47581506
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/47581506
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/47581506

Branch: refs/heads/GROOVY_2_4_X
Commit: 47581506ddb32833e1781125396ffc24be3b1984
Parents: f033336
Author: paulk <paulk@asert.com.au>
Authored: Fri Jun 16 02:09:35 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Fri Jun 16 02:11:03 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/47581506/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 57548ee..ae347fc 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -4148,9 +4148,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/47581506/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) {


Mime
View raw message