Type conversion in the Database API in 4.11

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 UTC