Option to return aliased column names from Mapper Raw SQL methods.
Currently, the methods DB.performQuery and DB.runQuery return a (List[String], List[List[Any]]) with the first item in the tuple being a List of column names.
When running a query with aliased column names, e.g.
The underlying field name (FirstName) is returned rather than the aliased name (GivenName).
It would be very useful to have the option of getting the aliased names instead - but obviously keep the existing behaviour as the default to maintain backwards compatibility. This is especially needed when joining two tables that have a column with the same name.
I believe that the code which does this currently is in the DB.resultSetTo and DB.resultSetToAny methods. Currently, the line which gets the column names reads:
A supplemental version to get the aliased names as an alternative should instead read:
This enhancement has been discussed on the mailing list in these threads:
should use getColumnLabel insead of getColumnName in DB.resultSetToXXX
Mapper - Column Labels vs Column Names
When running a query with aliased column names, e.g.
SELECT FirstName AS GivenName FROM accounts WHERE id = 1
The underlying field name (FirstName) is returned rather than the aliased name (GivenName).
It would be very useful to have the option of getting the aliased names instead - but obviously keep the existing behaviour as the default to maintain backwards compatibility. This is especially needed when joining two tables that have a column with the same name.
I believe that the code which does this currently is in the DB.resultSetTo and DB.resultSetToAny methods. Currently, the line which gets the column names reads:
val colNames = cntList.map(i => md.getColumnName(i))
A supplemental version to get the aliased names as an alternative should instead read:
val colNames = cntList.map(i => md.getColumnLabel(i))
This enhancement has been discussed on the mailing list in these threads:
should use getColumnLabel insead of getColumnName in DB.resultSetToXXX
Mapper - Column Labels vs Column Names
Leave a comment