W3C home > Mailing lists > Public > public-html@w3.org > February 2008

Type conversion in the Database API in 4.11

From: <mikko.honkala@nokia.com>
Date: Thu, 28 Feb 2008 16:42:52 +0200
Message-ID: <72FEB86533D5F643882E15DB52FEE75F04405AEA@esebe105.NOE.Nokia.com>
To: <public-html@w3.org>

Hello Group,

maybe I am missing something but the database API does not seem to
define type conversion rules between JavaScript types and the database.

For query results, in 4.11.4 
http://dev.w3.org/html5/spec/Overview.html#database
the spec says: "Each property must have the name of the column and the
value of the cell, as they were returned by the database.". It is
unclear what type this value is. 

For query parameters, 4.11.3 
http://dev.w3.org/html5/spec/Overview.html#executing
says "Replace each ? placeholder with the value of the argument". Which
datatypes can be used for the "value". How are they converted when
inserted into the DB?

My ECMAScript-specific proposal would be to preserve ECMAScript numbers
(64-bit double) and booleans, and treat the rest as strings. 

Pseudo-code for query parameter o:

typeof o
    "boolean" : ToNumber(o)
    "number"  : o
    object:
        instanceof o
            "Number" : ToNumber(o)
            "Boolean" : ToNumber(o)
            default: ToString(o)
    default: ToString(o)

ToNumber and ToString are pseudo-functions defined by ECMAScript spec.

Similarily, for query results, the mapping should be preserved.     

Of course, the SQL subset definition needs to define the datatypes that
the DB has to support. (ISSUE 36)

-mikko
Received on Thursday, 28 February 2008 14:43:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:12 GMT