Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
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+
-
Number of attachments :
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
Issue Links
- is related to
-
GROOVY-2782
SQL column aliases not recognized by groovy.sql methods
-
Sorry, my typing and proof reading is awful:
>> As both fields get put into the save field in the resultant row map.
Should be
As both fields get put into the same field ('description') in the resultant row map.