[CONJ-149] ResultSetMetaData.getTableName returns table alias instead of real table name Created: 2015-04-17  Updated: 2015-06-24  Resolved: 2015-06-23

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: None
Fix Version/s: 1.1.9

Type: Bug Priority: Major
Reporter: Rasmus Johansson (Inactive) Assignee: Rasmus Johansson (Inactive)
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Relates
relates to CONJ-163 make column label name display instea... Closed

 Description   

ResultSetMetaData.getTableName returns table alias instead of real table name in for example following type of query.

SELECT id FROM t1 AS t1_alias

Currently ResultSetMetaData.getTableName would return t1_alias.

ResultSetMetaData.getTableName should return the real table name and this was fixed in the MySQL Connector/J some years back. An URL parameter called useOldAliasMetadataBehavior was introduced if someone wants to continue using the old behaviour.



 Comments   
Comment by seung hoon yoo [ 2015-05-07 ]

Hello~

i think additional fix need about alias thing of column

please read : http://dev.mysql.com/doc/connector-j/en/connector-j-installing-upgrading-5-1.html

ResultSetMetaData.getColumnName() is display real column (mariadb connector/j 1.1.8ver) so
if attach parameter ( useOldAliasMetadataBehavior=true)
then ResultSetMetaData.getColumnName() need display alias column name as getColumnLabel().

(mysql connector done, mariadb connector not yet)

Like table, column alias need old behaviour

Thanks.

Comment by Vladislav Vaintroub [ 2015-05-14 ]

useOldAliasMetadataBehavior=true was backward compatibility fix for own non-JDBC compliant ConnectorJ behavior w.r.t column names, among other things. Whether MariaDBs driver should introduce a new feature with that parameter is a good question.

Comment by seung hoon yoo [ 2015-06-15 ]

hi~ I just 2 row add in 1.1.9 connector gihub script u contribute
that make column label name display instead column name when useOldAliasMetadataBehavior option true

how about my idea,
and would u add this source (2 line in MySQLResultSetMetaData.java) next release 1.1.9 ver??

MySQLResultSetMetaData.java

 public String getColumnName(final int column) throws SQLException {
        String s =  getColumnInformation(column).getOriginalName();      
+        if (returnTableAlias == true)    // if useOldAliasMetadataBehavior=true then getColumnName return getCoulmnLabel
+         s =  getColumnLabel(column); 
      
        if ("".equals(s))  // odd things that are no columns, e.g count(*)
            s =  getColumnLabel(column);
        return s;
    }

Generated at Thu Feb 08 03:13:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.