Page 1 of 1

Unsupported SQL Types in Azure Mobile Service schema inMSSQL

Posted: 08 Jul 2014, 11:16
by muhweli
Hello,

I'm new to SFS and as a part of my app, I was looking towards using my database directly through SFS. However, when I install the JDBC driver (4.0 from Microsoft homepage) and set up my database, I get a long bunch of

Code: Select all

12:25:25,034 INFO  [main] serialization.DefaultSFSDataSerializer     - Skipping Unsupported SQL TYPE: -2, Column:__version
12:25:25,035 INFO  [main] serialization.DefaultSFSDataSerializer     - Skipping Unsupported SQL TYPE: -155, Column:timestamp
12:25:25,036 INFO  [main] serialization.DefaultSFSDataSerializer     - Skipping Unsupported SQL TYPE: -155, Column:__createdAt


messages from SFS2x. I do need these fields (most of them are automatically generated by Azure Mobile Service) and they are of type datetime or datetimeoffset as per Transcript-SQL language.

What's the solution to this? It looks like writing a DataSerializer to replace the DefaultSFSDataSerializer would be the way to go, but I do not know how to do that.

Re: Unsupported SQL Types in Azure Mobile Service schema inM

Posted: 08 Jul 2014, 13:41
by Lapo
Hi,
you don't need to write a custom serializer but here's what the problem is in short. The SFS2X server API provide a higher level abstraction to access your DB that attempts to auto-magically serialize the resultset of query into a structured SFSObject which can be passed to clients in one line of code.

The database types supported are documented here:
http://docs2x.smartfoxserver.com/api-do ... ang.String)

... but of course every DB has a larger set of types that can be used.

So what to do if the SFS2X API don't support your specific MSSQL DB. You can still access the DB at a lower level by grabbing a connection from the DBManager, running your own queries and marshalling the data types manually. Eg: if you have a Date type you can turn it into a string to send it back to the client. Or you could transform it into a 64-bit long as a timestamp etc...

Check the examples in the docs, here:
http://docs2x.smartfoxserver.com/Develo ... se-recipes

Re: Unsupported SQL Types in Azure Mobile Service schema inM

Posted: 08 Jul 2014, 16:58
by muhweli
Thank you! This helped a ton. That being said, for future convenience value, if I wanted to extend the serializer to do this automagically instead of doing it for each table/query manually (which can be a pain since I have roughly 30 tables to work with now), how would I proceed with a custom serializer or is it doable?

Re: Unsupported SQL Types in Azure Mobile Service schema inM

Posted: 08 Jul 2014, 17:23
by Lapo
The Server API use a very low level serialization process that is hardly modifiable. This is not because it wasn't intended to be that way but because it is a pretty complex process the ramifications of which are also pretty vast.

SFSObjects in the SFS API can serialize a number of types, described here: http://docs2x.smartfoxserver.com/api-do ... oc/server/
which are natively supported by all platforms we target (C#, C++, Java, Actionscript, Objective-C etc...). Adding "new stuff" is far from simple because it must correspond to something else on each every platform.

Instead of going so deep down in the API to support for new types, it is much easier to use those primitive types to create new ones or simply convert to the closer existing type.

Example: if you have a decimal value you can convert it to a Double. A "timestamp", like in your case, doesn't have a direct correspondence to any native type, so you will need to find a way to convert it to something usable in your server or client code. You may convert it to a String or to 64-bit integer.

This process can be decided and executed at the level of the extension, so in your code.

To use an even more high-level approach you could use an implementation of JPA such as Hibernate or Eclipse Link and map your DB directly to Java objects, so you don't have to deal with primitive types etc...

Hope it helps

Re: Unsupported SQL Types in Azure Mobile Service schema inM

Posted: 01 Apr 2015, 01:46
by marsoups
I would like to request adding support to tinyint(1) , as this as defined as a Boolean in mySQL and is a very frequently used data type.

Always get this error on tinyint(1) data type, even though the documentation says that tinyint is supported:

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

Re: Unsupported SQL Types in Azure Mobile Service schema inMSSQL

Posted: 06 Jun 2018, 11:51
by sadensmol
I have problem with tinyint(1) too.
Serializer just skips these types (I have them in many places and it worked with sfs1 just fine)

What I have in logs:
serialization.DefaultSFSDataSerializer - Skipping Unsupported SQL TYPE: -7,

As a result sfsobject has not such type after the request.

I don't like to change the db as we work with this db from sfs and sfs2, and I don't like to go to raw db request as we already have all other logic with good jdbc-sfsobject serialisation and it's actually a bug (as you noted in your docs that it's working!)

Re: Unsupported SQL Types in Azure Mobile Service schema inMSSQL

Posted: 06 Jun 2018, 13:54
by sadensmol
Okay i fixed this problem with tinyInt1isBit=false for jdbc

Re: Unsupported SQL Types in Azure Mobile Service schema inMSSQL

Posted: 06 Jun 2018, 14:05
by Lapo
Ok, good to know :)