Page 1 of 1

MySQL field alias not supported?

Posted: 20 Jan 2011, 14:00
by dingo
Hi

I'm doing the following on the Server

Code: Select all

String sql = "SELECT users.id as sqlID FROM users WHERE users.id="+6;
ISFSArray queryRes = dbManager.executeQuery(sql);
The Dump i receive is:

Code: Select all

(sfs_object) 
		(int) id: 6
Note that the field is not returned as the alias (sqlID) as i requested.

This is obviously a big problem since it breaks complex queries such as:

Code: Select all

"SELECT users.id as sqlID, weapons.id as weaponID FROM ...."
Since both return id, they overwrite each other. Is there a fix for this already? Other than using the Java DB tools (which i just all converted to support SFS2X/ISFSArray :()

Also (but i think you're already aware of this), the field TINYINT(1) cannot be read (returns SKIPPING), TINYINT(4) however works.

Thanks.

Posted: 20 Jan 2011, 15:02
by dingo
Did some more testing, when doing the query with a java Statement.executeQuery(sql) it works fine.

But when i convert the returned ResultSet with SFSArray.newFromResultSet(queryRes), the alias is missing again.

Posted: 21 Jan 2011, 12:24
by Lapo
Yes I can confirm that aliasing is not supported at the moment.

Posted: 10 Mar 2011, 14:39
by stix
Try adding: ?useOldAliasMetadataBehavior=true
to the end of your connection string.

e.g.
jdbc:mysql://localhost:3306/sample_db?useOldAliasMetadataBehavior=true

That worked for us on 1.6. Haven't tried it on 2X, but worth a try.

Posted: 11 Mar 2011, 07:35
by Lapo
It might not work with the high level approach using the API but you can get a connection directly and use the JDBC framework freely without constraints. More details in the docs.

Posted: 20 Mar 2011, 15:26
by dingo
thanks for the hint stix, actually i remember having looked that up somewhere when i was using 1.6. haven't tried it yet.

Posted: 20 Mar 2011, 16:17
by dingo
tested it > works. Thanks!