Groovy
  1. Groovy
  2. GROOVY-3320

SQL Column Aliases are ignored by groovy.sql with MySQL

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.7
    • Fix Version/s: 1.6.3, 1.7-beta-1
    • Component/s: SQL processing
    • Labels:
      None
    • Environment:
      Connecting to MySQL 5 with Connector/J 5.1+

      Description

      I had a problem when joining two tables that shared a field name, ie:

      SELECT a.id, a.description, b.description FROM a JOIN b ON( a.b_fk = b.id )

      As both fields get put into the save field in the resultant row map.

      Trying to alias the rows doesn't help, ie;

      SELECT a.id, a.description AS a_desc, b.description AS b_desc FROM a JOIN b ON( a.b_fk = b.id )

      Gives the same.

      I found the reason for this ( http://jira.codehaus.org/browse/GROOVY-2782) which recommends adding the "useOldAliasMetadataBehavior=true" parameter to the JDBC url, and this does fix it, however in that issue, Ken Weiner asks:

      >> Should the rows method be calling ResultSetMetaData.getColumnLabel() instead?

      Which I thought was a good point, deserving of another issue.

      It's strange, and kinda unpredictable as it stands, as the following:

      SELECT 10, 10 AS ten

      Does give you two columns back (so the alias works) – but I guess this is a missed case on the original MySQL "fix"

      Hope this make sense... It's my first issue, and I've tried not to babble

      Cheers,

      Tim

      1. TestHelper.groovy
        3 kB
        Tim Yates
      2. diff.txt
        2 kB
        Tim Yates

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Paul King
              Reporter:
              Tim Yates
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development