groovy
  1. groovy
  2. GROOVY-5170

GroovyRowResult and GroovyResultSet are Inconsistent with each other when using a postgres driver

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.4
    • Fix Version/s: 1.8.6, 2.0-beta-3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Groovy with a postgres database
    • Number of attachments :
      1

      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)

      { row -> def eValue = row[column] println "each row found $eValue"; }

      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.

      1. bug.groovy
        5 kB
        Jeffrey Adamson

        Activity

          People

          • Assignee:
            Paul King
            Reporter:
            Jeffrey Adamson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: