Quantcast

groovy git commit: Sql, DataSet: Add @ClosureParams to closure parameters of following methods (closes #536): * asList * eachRow * each * query * rows * withStatement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

groovy git commit: Sql, DataSet: Add @ClosureParams to closure parameters of following methods (closes #536): * asList * eachRow * each * query * rows * withStatement

shils-2
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 8d2174d1d -> b11e8fcf2


Sql, DataSet: Add @ClosureParams to closure parameters of following methods (closes #536):
* asList
* eachRow
* each
* query
* rows
* withStatement


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

Branch: refs/heads/GROOVY_2_4_X
Commit: b11e8fcf258282cebbde4cbad86c28b8ce6f4848
Parents: 8d2174d
Author: Shil Sinha <[hidden email]>
Authored: Sun Apr 30 20:01:27 2017 -0400
Committer: Shil Sinha <[hidden email]>
Committed: Sun May 7 12:23:16 2017 -0400

----------------------------------------------------------------------
 .../src/main/java/groovy/sql/DataSet.java       |   7 +-
 .../src/main/java/groovy/sql/Sql.java           | 118 ++++++++++++-------
 .../test/groovy/groovy/sql/SqlSTCTest.groovy    |  82 +++++++++++++
 3 files changed, 164 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/b11e8fcf/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java b/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
index 0b4d08f..d53e637 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
@@ -20,6 +20,8 @@ package groovy.sql;
 
 import groovy.lang.Closure;
 import groovy.lang.GroovyRuntimeException;
+import groovy.transform.stc.ClosureParams;
+import groovy.transform.stc.SimpleType;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.MethodNode;
 import org.codehaus.groovy.ast.CodeVisitorSupport;
@@ -332,7 +334,7 @@ public class DataSet extends Sql {
      * @throws SQLException if a database access error occurs
      * @see groovy.sql.Sql#eachRow(String, java.util.List, groovy.lang.Closure)
      */
-    public void each(Closure closure) throws SQLException {
+    public void each(@ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(getSql(), getParameters(), closure);
     }
 
@@ -346,7 +348,8 @@ public class DataSet extends Sql {
      * @throws SQLException if a database access error occurs
      * @see groovy.sql.Sql#eachRow(String, java.util.List, int, int, groovy.lang.Closure)
      */
-    public void each(int offset, int maxRows, Closure closure) throws SQLException {
+    public void each(int offset, int maxRows,
+                     @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(getSql(), getParameters(), offset, maxRows, closure);
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/b11e8fcf/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 24c993d..57548ee 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -42,6 +42,8 @@ import javax.sql.DataSource;
 
 import groovy.lang.MissingPropertyException;
 import groovy.lang.Tuple;
+import groovy.transform.stc.ClosureParams;
+import groovy.transform.stc.SimpleType;
 import org.codehaus.groovy.runtime.InvokerHelper;
 
 import static org.codehaus.groovy.runtime.SqlGroovyMethods.toRowResult;
@@ -958,7 +960,7 @@ public class Sql {
      * @param closure called for each row with a <code>ResultSet</code>
      * @throws SQLException if a database access error occurs
      */
-    public void query(String sql, Closure closure) throws SQLException {
+    public void query(String sql, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure) throws SQLException {
         Connection connection = createConnection();
         Statement statement = null;
         ResultSet results = null;
@@ -998,7 +1000,7 @@ public class Sql {
      * @param closure called for each row with a <code>ResultSet</code>
      * @throws SQLException if a database access error occurs
      */
-    public void query(String sql, List<Object> params, Closure closure) throws SQLException {
+    public void query(String sql, List<Object> params, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure) throws SQLException {
         Connection connection = createConnection();
         PreparedStatement statement = null;
         ResultSet results = null;
@@ -1024,7 +1026,7 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void query(String sql, Map map, Closure closure) throws SQLException {
+    public void query(String sql, Map map, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure) throws SQLException {
         query(sql, singletonList(map), closure);
     }
 
@@ -1038,7 +1040,7 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void query(Map map, String sql, Closure closure) throws SQLException {
+    public void query(Map map, String sql, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure) throws SQLException {
         query(sql, singletonList(map), closure);
     }
 
@@ -1070,7 +1072,7 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @see #expand(Object)
      */
-    public void query(GString gstring, Closure closure) throws SQLException {
+    public void query(GString gstring, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure) throws SQLException {
         List<Object> params = getParameters(gstring);
         String sql = asSql(gstring, params);
         query(sql, params, closure);
@@ -1098,7 +1100,7 @@ public class Sql {
      * @param closure called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, Closure closure) throws SQLException {
+    public void eachRow(String sql, @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, (Closure) null, closure);
     }
 
@@ -1125,7 +1127,8 @@ public class Sql {
      * @param closure called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, int offset, int maxRows, Closure closure) throws SQLException {
+    public void eachRow(String sql, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, (Closure) null, offset, maxRows, closure);
     }
 
@@ -1159,7 +1162,8 @@ public class Sql {
      * @param rowClosure  called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, Closure metaClosure, Closure rowClosure) throws SQLException {
+    public void eachRow(String sql, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         eachRow(sql, metaClosure, 0, 0, rowClosure);
     }
 
@@ -1190,7 +1194,9 @@ public class Sql {
      * @param rowClosure  called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
+    public void eachRow(String sql,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         Connection connection = createConnection();
         Statement statement = null;
         ResultSet results = null;
@@ -1254,7 +1260,9 @@ public class Sql {
      * @param rowClosure  called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, List<Object> params, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
+    public void eachRow(String sql, List<Object> params,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         Connection connection = createConnection();
         PreparedStatement statement = null;
         ResultSet results = null;
@@ -1291,7 +1299,9 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(String sql, Map map, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
+    public void eachRow(String sql, Map map,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         eachRow(sql, singletonList(map), metaClosure, offset, maxRows, rowClosure);
     }
 
@@ -1308,7 +1318,9 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(Map map, String sql, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
+    public void eachRow(Map map, String sql,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         eachRow(sql, singletonList(map), metaClosure, offset, maxRows, rowClosure);
     }
 
@@ -1346,7 +1358,9 @@ public class Sql {
      * @param rowClosure  called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, List<Object> params, Closure metaClosure, Closure rowClosure) throws SQLException {
+    public void eachRow(String sql, List<Object> params,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         eachRow(sql, params, metaClosure, 0, 0, rowClosure);
     }
 
@@ -1361,7 +1375,9 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(String sql, Map params, Closure metaClosure, Closure rowClosure) throws SQLException {
+    public void eachRow(String sql, Map params,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         eachRow(sql, singletonList(params), metaClosure, rowClosure);
     }
 
@@ -1376,7 +1392,9 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(Map params, String sql, Closure metaClosure, Closure rowClosure) throws SQLException {
+    public void eachRow(Map params, String sql,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         eachRow(sql, singletonList(params), metaClosure, rowClosure);
     }
 
@@ -1400,7 +1418,8 @@ public class Sql {
      * @param closure called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, List<Object> params, Closure closure) throws SQLException {
+    public void eachRow(String sql, List<Object> params,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, params, null, closure);
     }
 
@@ -1414,7 +1433,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(String sql, Map params, Closure closure) throws SQLException {
+    public void eachRow(String sql, Map params,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, singletonList(params), closure);
     }
 
@@ -1428,7 +1448,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(Map params, String sql, Closure closure) throws SQLException {
+    public void eachRow(Map params, String sql,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, singletonList(params), closure);
     }
 
@@ -1455,7 +1476,8 @@ public class Sql {
      * @param closure called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(String sql, List<Object> params, int offset, int maxRows, Closure closure) throws SQLException {
+    public void eachRow(String sql, List<Object> params, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, params, null, offset, maxRows, closure);
     }
 
@@ -1471,7 +1493,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(String sql, Map params, int offset, int maxRows, Closure closure) throws SQLException {
+    public void eachRow(String sql, Map params, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, singletonList(params), offset, maxRows, closure);
     }
 
@@ -1487,7 +1510,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public void eachRow(Map params, String sql, int offset, int maxRows, Closure closure) throws SQLException {
+    public void eachRow(Map params, String sql, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(sql, singletonList(params), offset, maxRows, closure);
     }
 
@@ -1524,7 +1548,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @see #expand(Object)
      */
-    public void eachRow(GString gstring, Closure metaClosure, Closure rowClosure) throws SQLException {
+    public void eachRow(GString gstring, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         List<Object> params = getParameters(gstring);
         String sql = asSql(gstring, params);
         eachRow(sql, params, metaClosure, rowClosure);
@@ -1555,7 +1580,9 @@ public class Sql {
      * @param rowClosure  called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(GString gstring, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
+    public void eachRow(GString gstring,
+                        @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure rowClosure) throws SQLException {
         List<Object> params = getParameters(gstring);
         String sql = asSql(gstring, params);
         eachRow(sql, params, metaClosure, offset, maxRows, rowClosure);
@@ -1583,7 +1610,8 @@ public class Sql {
      * @param closure called for each row with a GroovyResultSet
      * @throws SQLException if a database access error occurs
      */
-    public void eachRow(GString gstring, int offset, int maxRows, Closure closure) throws SQLException {
+    public void eachRow(GString gstring, int offset, int maxRows,
+                        @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         List<Object> params = getParameters(gstring);
         String sql = asSql(gstring, params);
         eachRow(sql, params, offset, maxRows, closure);
@@ -1610,7 +1638,7 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @see #expand(Object)
      */
-    public void eachRow(GString gstring, Closure closure) throws SQLException {
+    public void eachRow(GString gstring, @ClosureParams(value=SimpleType.class, options="groovy.sql.GroovyResultSet") Closure closure) throws SQLException {
         eachRow(gstring, null, closure);
     }
 
@@ -1678,7 +1706,8 @@ public class Sql {
      * @return a list of GroovyRowResult objects
      * @throws SQLException if a database access error occurs
      */
-    public List<GroovyRowResult> rows(String sql, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(String sql, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure)
+            throws SQLException {
         return rows(sql, 0, 0, metaClosure);
     }
 
@@ -1706,7 +1735,8 @@ public class Sql {
      * @return a list of GroovyRowResult objects
      * @throws SQLException if a database access error occurs
      */
-    public List<GroovyRowResult> rows(String sql, int offset, int maxRows, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(String sql, int offset, int maxRows,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         AbstractQueryCommand command = createQueryCommand(sql);
         // for efficiency set maxRows (adjusted for the first offset rows we are going to skip the cursor over)
         command.setMaxRows(offset + maxRows);
@@ -1896,8 +1926,8 @@ public class Sql {
      * @return a list of GroovyRowResult objects
      * @throws SQLException if a database access error occurs
      */
-    public List<GroovyRowResult> rows(String sql, List<Object> params, Closure metaClosure)
-            throws SQLException {
+    public List<GroovyRowResult> rows(String sql, List<Object> params,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         return rows(sql, params, 0, 0, metaClosure);
     }
 
@@ -1912,7 +1942,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public List<GroovyRowResult> rows(String sql, Map params, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(String sql, Map params,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         return rows(sql, singletonList(params), metaClosure);
     }
 
@@ -1927,7 +1958,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public List<GroovyRowResult> rows(Map params, String sql, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(Map params, String sql,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         return rows(sql, singletonList(params), metaClosure);
     }
 
@@ -1960,9 +1992,8 @@ public class Sql {
      * @return a list of GroovyRowResult objects
      * @throws SQLException if a database access error occurs
      */
-    public List<GroovyRowResult> rows(String sql, List<Object> params, int offset, int maxRows, Closure metaClosure)
-            throws SQLException {
-
+    public List<GroovyRowResult> rows(String sql, List<Object> params, int offset, int maxRows,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         AbstractQueryCommand command = createPreparedQueryCommand(sql, params);
         // for efficiency set maxRows (adjusted for the first offset rows we are going to skip the cursor over)
         command.setMaxRows(offset + maxRows);
@@ -1986,7 +2017,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public List<GroovyRowResult> rows(String sql, Map params, int offset, int maxRows, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(String sql, Map params, int offset, int maxRows,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         return rows(sql, singletonList(params), offset, maxRows, metaClosure);
     }
 
@@ -2003,7 +2035,8 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @since 1.8.7
      */
-    public List<GroovyRowResult> rows(Map params, String sql, int offset, int maxRows, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(Map params, String sql, int offset, int maxRows,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         return rows(sql, singletonList(params), offset, maxRows, metaClosure);
     }
 
@@ -2077,7 +2110,7 @@ public class Sql {
      * @throws SQLException if a database access error occurs
      * @see #expand(Object)
      */
-    public List<GroovyRowResult> rows(GString gstring, Closure metaClosure)
+    public List<GroovyRowResult> rows(GString gstring, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure)
             throws SQLException {
         List<Object> params = getParameters(gstring);
         String sql = asSql(gstring, params);
@@ -2109,7 +2142,8 @@ public class Sql {
      * @return a list of GroovyRowResult objects
      * @throws SQLException if a database access error occurs
      */
-    public List<GroovyRowResult> rows(GString gstring, int offset, int maxRows, Closure metaClosure) throws SQLException {
+    public List<GroovyRowResult> rows(GString gstring, int offset, int maxRows,
+                                      @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         List<Object> params = getParameters(gstring);
         String sql = asSql(gstring, params);
         return rows(sql, params, offset, maxRows, metaClosure);
@@ -3462,7 +3496,7 @@ public class Sql {
      *
      * @param configureStatement the closure
      */
-    public void withStatement(Closure configureStatement) {
+    public void withStatement(@ClosureParams(value=SimpleType.class, options="java.sql.Statement") Closure configureStatement) {
         this.configureStatement = configureStatement;
     }
 
@@ -3927,11 +3961,13 @@ public class Sql {
      * @return the resulting list of rows
      * @throws SQLException if a database error occurs
      */
-    protected List<GroovyRowResult> asList(String sql, ResultSet rs, Closure metaClosure) throws SQLException {
+    protected List<GroovyRowResult> asList(String sql, ResultSet rs,
+                                           @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         return asList(sql, rs, 0, 0, metaClosure);
     }
 
-    protected List<GroovyRowResult> asList(String sql, ResultSet rs, int offset, int maxRows, Closure metaClosure) throws SQLException {
+    protected List<GroovyRowResult> asList(String sql, ResultSet rs, int offset, int maxRows,
+                                           @ClosureParams(value=SimpleType.class, options="java.sql.ResultSetMetaData") Closure metaClosure) throws SQLException {
         List<GroovyRowResult> results = new ArrayList<GroovyRowResult>();
 
         try {

http://git-wip-us.apache.org/repos/asf/groovy/blob/b11e8fcf/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlSTCTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlSTCTest.groovy b/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlSTCTest.groovy
new file mode 100644
index 0000000..fa2da7f
--- /dev/null
+++ b/subprojects/groovy-sql/src/test/groovy/groovy/sql/SqlSTCTest.groovy
@@ -0,0 +1,82 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.sql
+
+import groovy.transform.TypeChecked
+import org.codehaus.groovy.control.CompilerConfiguration
+import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer
+
+class SqlSTCTest extends GroovyShellTestCase {
+
+    @Override
+    GroovyShell createNewShell() {
+        def config = new CompilerConfiguration().addCompilationCustomizers(new ASTTransformationCustomizer(TypeChecked))
+        new GroovyShell(config)
+    }
+
+    void testEachRow() {
+        shell.evaluate '''
+            def test(groovy.sql.Sql sql) {
+                sql.eachRow('SELECT * FROM FOO', { println it.columnCount }) {
+                    java.sql.Date date = it.getDate(1); println it[1]
+                }
+            }
+        '''
+    }
+
+    void testEach() {
+        shell.evaluate '''
+            def test(groovy.sql.DataSet ds) {
+                ds.each { java.sql.Date date = it.getDate(1); println it[1] }
+            }
+        '''
+    }
+
+    void testQuery() {
+        shell.evaluate '''
+            def test(groovy.sql.Sql sql) {
+                sql.query('SELECT * FROM FOO') { java.sql.Date date = it.getDate(1) }
+            }
+        '''
+    }
+
+    void testRows() {
+        shell.evaluate '''
+            def test(groovy.sql.Sql sql) {
+                sql.rows('SELECT * FROM FOO') { println it.columnCount }
+            }
+        '''
+    }
+
+    void testAsList() {
+        shell.evaluate '''
+            def test(groovy.sql.Sql sql, java.sql.ResultSet rs) {
+                sql.asList('SELECT * FROM FOO', rs) { println it.columnCount }
+            }
+        '''
+    }
+
+    void testWithStatement() {
+        shell.evaluate '''
+            def test(groovy.sql.Sql sql) {
+                sql.withStatement { it.maxRows = 10 }
+            }
+        '''
+    }
+}
\ No newline at end of file

Loading...