Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.4
-
None
-
None
-
Groovy with a postgres database
Description
Basically, the root problem seams to be that the postgres (driver?) folds unquoted object identifiers to lower case. This behavior is transparent to the api when using sql.eachRow, but not when sql.firstRow. This appears to be related to how eachRow uses a GroovyResultSet which delegates the getObject(property) to the driver, but firstRow uses a GroovyRowResult which does not.
String query = "SELECT * FROM $table";
sql.eachRow(query)
def fValue = sql.firstRow(query)[column]
println "firstRow found $fValue"
I saw code in GroovyRowResult#getProperty(String) currently checks the exact case, then tries folding the property name to upper-case (as is more common). This is not adequate for postgres behavior which folds to lower-case.
Attached is a script which demonstrates this, an example invocation would be
`bug.groovy --url jdbc:postgresql://example.com:5432/catalog --user postgres --pass postgres --schema public --driver org.postgresql.Driver TABLE ID`
It requires a postgres database with a table and column (create using unquoted and/or lowercase names) exist with at least one row.