groovy/groovy-core — pull request #216 by jwagenleitner (2013-07-05 19:09:25+00:00)
Title: GROOVY-5436: Enable use of parameter list in SQL IN Clause

Currently if a collection or array type is included in the parameters for a query a `java.sql.SQLException: Invalid column type` is thrown. So this change assumes that there was no use of those types in parameters previously. This change will expand those parameters in placeholders such that a 3 element array would become `(?,?,?)`. No checking is done to ensure the `IN` operator is the actual operator for the parameter, so would work for other operators that take lists of parameters enclosed in parens (such as Oracle ANY or ALL operators).

This change moves the updating of the user supplied params to the sql parsing phase (in `ExtractIndexAndSql`). One limitation that I know of is that it does not work in the `withBatch` family of methods. Since the parameters for those methods are not known at the time the sql is parsed for parameters and given the nature of those methods, it seemed like an acceptable trade-off.

Given that this is a significant change that introduces risk, there haven't been a lot of votes on the issue and there is a reasonable workaround using `Sql.expand`, I can understand why this wouldn't be accepted. But thought I would at least offer it up.