Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Not A Bug
-
Affects Version/s: 1.6-beta-1
-
Fix Version/s: None
-
Component/s: SQL processing
-
Labels:None
-
Environment:WinXP, Java 1.6, MySQL 5, mysql-connector-java-3.1.10-bin.jar
-
Number of attachments :
Description
Using Groovy SQL returns the wrong values for some columns. Strangely it depends on the form of the SQL - whether it is parameterized or not, or whether it's passed as a plain String or a GString.
Sample reproduction code:
----------
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/test_db","root","","com.mysql.jdbc.Driver")
sql.execute("create table test_groovy ( id int(10) unsigned )");
sql.executeInsert("insert into test_groovy values (2)")
def selectId = 2;
def row = sql.firstRow("select * from test_groovy where id = $
println "First row has value ${row.id}"
row = sql.firstRow("select * from test_groovy where id = ${selectId}
")
println "First row has value $
row = sql.firstRow("select * from test_groovy where id = ?",[ selectId ])
println "First row has value ${row.id}
"
row = sql.firstRow("select * from test_groovy where id = " + selectId)
println "First row has value $
"
sql.execute("drop table test_groovy")
------
When run this produces the following output:
First row has value 4294967298
First row has value 4294967298
First row has value 4294967298
First row has value 2
------
Expected output:
First row has value 2
First row has value 2
First row has value 2
First row has value 2