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 
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 
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
        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)


Received on Thursday, 28 February 2008 14:43:09 UTC