Page 1 of 1

SFSObject mapping to MySQL query

Posted: 14 Apr 2015, 09:21
by marsoups
Hi!

I'd like to make a request that I think will be pretty useful to development, as often times there are cases where using the db.executeQuery(query, obj[]) method is very useful, but there is a limitation if there is an "AS" alias in the query. Sometimes the "AS" clause (eg. SELECT `id` AS user_id ) is required in a query because two fields in a cross-query have the same name, or you'd like to conveniantly shorten the field names and package them as such into the SFSObject.

On testing, I found that the ResultSetMetaData from a ResultSet contains two functions : getColumnLabel() and getColumnName()

The getColumnName() method uses the original name and not the new alias, so I was wondering if it's possible to use the getColumnLabel() instead from the ResultSetMetaData, as this is more conveniant to structure the resulting SFSObject with ease. In some situations, there is no choice but to manually generate the SFSObject, in such circumstances.

Another request is to allow tinyint(1) types as Boolean objects in a result, otherwise there is an error appearing

Code: Select all

serialization.DefaultSFSDataSerializer     - Skipping Unsupported SQL TYPE: -7
Thanks

Re: SFSObject mapping to MySQL query

Posted: 15 Apr 2015, 08:13
by Lapo
Hi,
we'll investigate the getColumnLabel() and getColumnName() options. If there are no side effects from switching to the other, with the added bonus of aliasing, we'll use that instead.

The problem with TinyInt is that in JDBC it is defined as an 8-bit integer, the equivalent of the native type byte, not a Boolean. So this would be more of a MySQL-specific trick, but we don't detect the database type at runtime.


thanks