Skip to content

Commit

Permalink
Sql, DataSet: Add @ClosureParams to closure parameters of following m…
Browse files Browse the repository at this point in the history
…ethods (closes apache#536):

* asList
* eachRow
* each
* query
* rows
* withStatement
  • Loading branch information
shils committed May 7, 2017
1 parent 8680457 commit 67ccb14
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 43 deletions.
7 changes: 5 additions & 2 deletions subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

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;
Expand Down Expand Up @@ -332,7 +334,7 @@ public DataSet reverse() {
* @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);
}

Expand All @@ -346,7 +348,8 @@ public void each(Closure closure) throws SQLException {
* @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);
}

Expand Down
Loading

0 comments on commit 67ccb14

Please sign in to comment.