W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

[webdatabase] Handling of the query arguments

From: João Eiras <joaoe@opera.com>
Date: Thu, 19 Nov 2009 23:12:51 +0100
To: "public-webapps@w3.org" <public-webapps@w3.org>
Message-ID: <op.u3nxbppf2q99of@id-c0981>

Hi everyone.

Neither the web database specification, nor the IDL, specify the fine  
grained handling that implementation must do of the several possible  
values that can be passed in the 2nd argument to executeSql, considering  
that those ecmascript values need to be handled by the SQL engine, and  
therefore converted into a database compatible value.

The only reference to the arguments is the paragraph that tell that the  
arguments should be replaced, but I've already asked that paragraph  
language to be reviewed in

Handling of ecmascript to database types could be done the following way:
  - numerical values would be converted to REAL
  - strings would be converted to TEXT, including the empty string
  - booleans would be converted to lowercase TEXT "false" or "true"
  - null and undefined would be handled as NULL
  - functions would be converted to TEXT

Objects, which do not fit the primitive types about, can be handled in two  

1) The quick cheap way, which was already hinted, would be to convert them  
to string.
However, that's not very helpful, if the object is a native type wrapper  
  new String("aa");
  new Number(1);
  new Boolean(true)

2) We can define, in the Web IDL, how an object can be converted to a  
primitive type.
Specifically, in an ecmascript binding we can do the following (note:  
returns means to stop the steps):
  - if object is null, return null
  - if object has a member function called valueOf, invoke valueOf in the  
context of object
    - if the returned value is a primitive type, return the value,
  - if object has a member function called toString, invoke toString in the  
context of object
    - if the returned value is a primitive type, return the value,
  - return Object.prototype.toString.call(object), so we get "[object  

The returned primitive type would then go through the ecmascript to  
database type steps above.

However, the Web IDL need to be language agnostic, so I'll leave for the  
Web IDL maintainers to decide if this is of its scope and specifiable.

There might need to be clarification on how to define what is a "numerical  
value", a "string", a "boolean", null and undefined, and functions.
We could say that a "numerical value" is just a number, but ideally, it  
should also include Number() instances, despite these could return non  
numerical values from their valueOf, but then we would go into the  
object-to-primitive steps.

The complete, we need the specification to tell how to convert database  
types back into ecmascript object, but this is easier:
  - TEXT, and other text types are converted to DOMString
  - REAL and other number types are converted to double
  - NULL is converted to null
  - DATE/TIMESTAMP types should be converted to Date objects, if supported

Thank you for your time.


João Eiras
Core Developer, Opera Software ASA, http://www.opera.com/
Received on Thursday, 19 November 2009 22:13:26 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:20 UTC