Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5170

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.4
    • 1.8.6, 2.0-beta-3
    • 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)

      { 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.

      Attachments

        1. bug.groovy
          5 kB
          Jeffrey Adamson

        Activity

          People

            paulk Paul King
            jwadamson Jeffrey Adamson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: