[
https://issues.apache.org/jira/browse/GROOVY-8128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15942717#comment-15942717
]
Paul King commented on GROOVY-8128:
-----------------------------------
I think I know what changes I'd make but I haven't been able to replicate the
problem to give myself confidence in the change. I tried hsqldb, mysql and
postgresql but couldn't get the error.
Here is what I tried:
{code}
@GrabConfig(systemClassLoader=true)
//@Grab('org.hsqldb:hsqldb:2.3.2')
//@Grab('mysql:mysql-connector-java:5.1.21')
//@Grab('postgresql:postgresql:9.0-801.jdbc4')
@Grab('org.postgresql:postgresql:42.0.0')
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:postgresql://localhost:5432/postgres",
"username", "password", "org.postgresql.Driver")
sql.execute 'DROP TABLE IF EXISTS A'
sql.execute 'CREATE TABLE A(x varchar(30))'
sql.execute "INSERT INTO A SELECT ? UNION SELECT ?", ['23', '45']
List rows = sql.rows('select * from A')
println "There are ${rows.size()} A row(s):"
println rows.collect { "$it.x" }.join(", ")
{code}
which produces:
{noformat}
There are 2 A row(s):
23, 45
{noformat}
> Breaking change in 2.4.9 with Sql query with GString
> ----------------------------------------------------
>
> Key: GROOVY-8128
> URL: https://issues.apache.org/jira/browse/GROOVY-8128
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 2.4.9
> Environment: Windows 7
> Reporter: Mike Sauer
> Priority: Critical
>
> The following code worked for releases 2.4.8 and below:
> {code}
> def query = """\
> SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED\r\n\
> select u5f_documenttype from DocVersion dv left outer join
> ClassDefinition cd on dv.object_class_id = cd.object_id
> where cd.symbolic_name in ('Retail', 'RetailWeb') and dv.is_current = 1
> and u59_accountnumber = $acctNum and u5f_documenttype = 'Signature Card'
> """
> def docFound = 'No Doc'
> consumerSql.eachRow(query) {
> {code}
> This code now fails in 2.4.9 and 2.4.10 with:
> {noformat}
> Mar 22, 2017 9:23:43 AM groovy.sql.Sql eachRow
> WARNING: Failed to execute: SET TRANSACTION ISOLATION LEVEL READ
> UNCOMMITTED
> select u5f_documenttype from DocVersion dv left outer join
> ClassDefinition cd on dv.object_class_id = cd.object_id
> where cd.symbolic_name in ('Retail', 'RetailWeb') and dv.is_current = 1
> and u59_accountnumber = ? and u5f_documenttype = 'Signature Card'
> because: com.microsoft.sqlserver.jdbc.SQLServerException: Unable to
> identify the table SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
> select u5f_documenttype from DocVersion dv left outer join
> ClassDefinition cd on dv.object_class_id = cd.object_id
> where cd.symbolic_name in ('Retail', 'RetailWeb') and dv.is_current = 1
> and u59_accountnumber = ? and u5f_documenttype = 'Signature Card'
> for the metadata.
> {noformat}
> I have tried changing to using placeholders and name parameters and I get
> similar results.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)