storesafe / cordova-sqlite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android, iOS and Windows with HTML5/Web SQL API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use named params?

DanielSWolf opened this issue · comments

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?

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

As discussed in brodybits/ask-me-anything#3, I have started a redesign and recently pushed some updates to support the named parameters on Android, iOS, and macOS. Integration with the features in this plugin and on other platforms such as Windows is now for future consideration.

Hello, is this feature now available for Android now ?