Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

[Bug] Transaction call without error callback causes "TypeError: undefined is not a function" error when the transaction fails. #1431

Open
brunoluigi opened this issue May 11, 2017 · 0 comments

Comments

@brunoluigi
Copy link

brunoluigi commented May 11, 2017

The SQLitePlugin transaction function expects an error callback as second parameter:

  SQLitePlugin.prototype.transaction = function(fn, error, success) {
    if (!this.openDBs[this.dbname]) {
      error(newSQLError('database not open'));
      return;
    }
    this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, true, false));
  };

But ng-cordova calls it without passing an error callback:

      execute: function (db, query, binding) {
        var q = $q.defer();
        db.transaction(function (tx) {
          tx.executeSql(query, binding, function (tx, result) {
              q.resolve(result);
            },
            function (transaction, error) {
              q.reject(error);
            });
        });
        return q.promise;
      },

Whenever the transaction fails it throws a nasty "TypeError: undefined is not a function" since error callback is undefined.

I'm working on a fix and will make a PR soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant