andpor/react-native-sqlite-storage

executeSql hangs when sending boolean values as params

anativ opened this issue · 3 comments

When calling executeSql with boolean value as param the function hangs on IOS
no callback at all success / error
Pull request #61 converts boolean to 0/1

Update: it doesn't happen when running with Chrome debugger

If we apply this change , it will be backward incompatible...
@brodybits - will it be enough to bump up the version to 3.1.0 ?

That's fine for me. I have a couple more suggestions:

  • make sure the boolean true and false values are covered by your the automatic test suite
  • document clearly that the boolean type (true and false values) are now properly supported

I think we can deduce that PR #61 is correct according to the draft Web SQL database standard [1] sections 4.2 and 5 (released in November 2010). Section 4.2 [2] specifies how to bind each "?" placeholder. According to section 5 [3]:

User agents must implement the SQL dialect supported by Sqlite 3.6.19.

When converting bound arguments to SQL data types, the JavaScript ToPrimitive abstract operation must be applied to obtain the raw value to be processed. [ECMA262].

We generally support SQLite 3.7.x and 3.8.x which should be very close to the "SQL dialect" supported by SQLite 3.6.19. According to ECMA 262 5.1 [4](June 2011) section 9.1 [5] there is no conversion from the Boolean type. Then according to [6] SQLite 3.x.x: "Boolean values are stored as integers 0 (false) and 1 (true)."

I am now considering whether or not to apply a similar fix to the Cordova sqlite plugin.

[1] https://www.w3.org/TR/webdatabase/
[2] https://www.w3.org/TR/webdatabase/#parsing-and-processing-sql-statements
[3] https://www.w3.org/TR/webdatabase/#web-sql
[4] http://www.ecma-international.org/ecma-262/5.1/
[5] http://www.ecma-international.org/ecma-262/5.1/#sec-9.1
[6] https://www.sqlite.org/datatype3.html#section_2_1

part of 3.1.0 release