3

https://www.w3.org/TR/webdatabase/#sqlstatementerrorcallback

See here that the sql statement error callback defines return type boolean :

[Callback=FunctionOnly, NoInterfaceObject]
interface SQLStatementErrorCallback {
  boolean handleEvent(in SQLTransaction transaction, in SQLError error);
};

Oppose that to

[Callback=FunctionOnly, NoInterfaceObject]
interface SQLTransactionErrorCallback {
  void handleEvent(in SQLError error);
};

Nowhere does it specify what the callback should return, and why it is a boolean.

many bindings, like the dart one for example ( https://api.dartlang.org/stable/2.4.0/dart-web_sql/SqlStatementErrorCallback.html ) have even defined it as void ( resulting in falsy? )

https://github.com/xpbrew/cordova-sqlite-storage/blob/dev/www/SQLitePlugin.js#L401 even throws an error if you do not return false.

I do realise it is a deprecated spec, but cordova chooses to be spec compliant here, so I need to be sure about how I interpret it.

Why is a statement error callback a boolean while transaction error callback for example is void ? What should I actually return in which scenario?

Boyen
  • 1,429
  • 2
  • 15
  • 22

1 Answers1

2

I have found a possible answer here: https://docs.kony.com

SQLStatementErrorCallback returns a boolean value.

  • true - ends the execution of the transaction. true is returned if there is no callback function specified as a parameter. Important: When true is returned, the transaction is rolled back.
  • false - continues executing the transaction.

This way you can decide if you want to continue or roll back whole transaction.

As for SQLTransactionErrorCallback- there are no possible uses for return value.

Swayok
  • 436
  • 3
  • 12