MySQL field alias not supported?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

dingo
Posts: 97
Joined: 27 Jan 2009, 21:34

MySQL field alias not supported?

Postby dingo » 20 Jan 2011, 14:00

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.
dingo
Posts: 97
Joined: 27 Jan 2009, 21:34

Postby dingo » 20 Jan 2011, 15:02

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.
User avatar
Lapo
Site Admin
Posts: 21726
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Jan 2011, 12:24

Yes I can confirm that aliasing is not supported at the moment.
Lapo
--
gotoAndPlay()
...addicted to flash games
stix
Posts: 9
Joined: 01 May 2010, 15:51

Postby stix » 10 Mar 2011, 14:39

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.
User avatar
Lapo
Site Admin
Posts: 21726
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 Mar 2011, 07:35

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.
Lapo

--

gotoAndPlay()

...addicted to flash games
dingo
Posts: 97
Joined: 27 Jan 2009, 21:34

Postby dingo » 20 Mar 2011, 15:26

thanks for the hint stix, actually i remember having looked that up somewhere when i was using 1.6. haven't tried it yet.
dingo
Posts: 97
Joined: 27 Jan 2009, 21:34

Postby dingo » 20 Mar 2011, 16:17

tested it > works. Thanks!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Aldenea, DavinVicy, DerikFent, JerodSa, Kevengar and 23 guests