Cordova-sqlite-storage: How to use named params?

Created on 7 Sep 2017  路  5Comments  路  Source: storesafe/cordova-sqlite-storage

The second parameter of executeSql contains values to be passed to SQLite as bind parameters. According to the SQLite documentation, such parameters can be positional or named. So I was expecting the following to work:

executeSql(
  'select * from Assignment where id = :assignmentId',
  { assignmentId: 42 },
  success, error);

However, this doesn't seem to work. How can I use named params with the Cordova SQLite storage plugin?

enhancement question doc-todo testing discussion suggestion doc-pitfall

Most helpful comment

This feature is now part of the discussion of an improved API with a redesigned implementation in #862.

All 5 comments

https://sqlite.org/lang_expr.html#varparam

Named parameters are not part of the Web SQL DRAFT API and also not supported by this plugin.

It would be a nice feature to support. I do not expect to support this in the near future. For future consideration.

This idea is marked as a possible enhancement for discussion. I would consider this to be a major change, especially in the evcore/evplus versions, and it would not be easy to support on the browser platform, which is part of the plan for the next major release in #687. (Clumsy alternative would be to use https://github.com/kripken/sql.js/ to support browser platform, for testing purposes. Not recommended and not guaranteed to work.)

In case you really want this change I would like to do this as part of a possible redesign, possibly based on the evcore implementation and probably with a much simpler JavaScript API (maybe similar to node-sqlite3, Promise-based API should be no problem). I would be happy to send you an estimate within the next few days in case you are interested.

P.S. If desired I would probably implement this change as part of a possible redesign discussed in #548.

This feature is now part of the discussion of an improved API with a redesigned implementation in #862.

+1 For this feature

Was this page helpful?
0 / 5 - 0 ratings