History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2146
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: Andreas Rudolf
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

Can't insert null values into database

Created: 26/Sep/07 07:09 AM   Updated: 08/Feb/08 01:26 AM
Component/s: SQL processing
Affects Version/s: 1.0, 1.1-beta-3
Fix Version/s: 1.5.2

Time Tracking:
Not Specified

File Attachments: 1. File InsertNullIntoDBTest.groovy (0.6 kb)

Environment:
CYGWIN_NT-5.1 <censored> 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
Issue Links:
Duplicate
 
Related
 

Testcase included: yes


 Description  « Hide
groovy failed to insert a null ( a.k . Undefined ) value into database using GString.

See source of attached testcase

Testcase return:
testNullInsert(InsertNullIntoDBTest)java.sql.SQLException: Unexpected token: ) in statement [INSERT INTO COUNTRY (country,currency) VALUES (?,)]



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Andreas Rudolf - 11/Dec/07 07:04 AM
I checked this again against Version 1.5 of groovy.
Testcase still failed

Paul King - 30/Dec/07 03:11 AM
Improvements have been made which should fix this problem but the test suite is fairly minimal in this area - please test as much as you can.

Phil Walker - 03/Feb/08 11:45 AM
The test script InsertNullIntoDBTest.groovy does not fail running under GroovyGroovy 1.5.3 JVM : 1.6.0_03-b05 (Ubuntu Linux).

However, the following slight variation does fail:

db.execute "INSERT INTO COUNTRY (country,currency) VALUES (?,?)",[it.key,it.value]

with the following output:

US USD
DE EUR
GB null
Caught: org.postgresql.util.PSQLException: No value specified for parameter 2.
at InsertNullIntoDBTest$_run_closure1.doCall(InsertNullIntoDBTest.groovy:19)
at InsertNullIntoDBTest.run(InsertNullIntoDBTest.groovy:17)
at InsertNullIntoDBTest.main(InsertNullIntoDBTest.groovy)


Paul King - 04/Feb/08 04:04 AM - edited
You might need to provide more info. This script:
Map countryMap = ['US' : 'USD', 'DE' : 'EUR', 'GB' : null]

countryMap.each{
    println it.key + " " + it.value
    db.execute "INSERT INTO COUNTRY (country,currency) VALUES (?,?)", [it.key, it.value]
}

works for me on 1.5.4 using hsql.


Paul King - 06/Feb/08 04:08 PM
This seems related to GROOVY-2585 perhaps it was only working on HSQL and would fail on other databases. Leaving this issue closed but follow the other issue for further progress.

Paul King - 08/Feb/08 01:26 AM
close off release 1.5.4