Comparing version 2.0.2 to 2.0.3
@@ -36,13 +36,3 @@ 'use strict'; | ||
function done(rollbackOrCommitError, results) { | ||
var error = err || rollbackOrCommitError || null; | ||
if (!error && typeof results !== "undefined") { | ||
for (var i = 0; i < results.length; i++) { | ||
var result = results[i]; | ||
if (result.error) { | ||
error = result.error; | ||
break; | ||
} | ||
} | ||
} | ||
function done(error) { | ||
if (error) { | ||
@@ -58,8 +48,36 @@ self._currentTask.errorCallback(error); | ||
function rollbackDone(error) { | ||
// Ignoring ROLLBACK errors as per | ||
// https://www.sqlite.org/lang_transaction.html#response_to_errors_within_a_transaction | ||
return function() { | ||
done(error); | ||
}; | ||
} | ||
function findErrorInResults(results) { | ||
for (var i = 0; i < results.length; i++) { | ||
var result = results[i]; | ||
if (result.error) { | ||
return result.error; | ||
} | ||
} | ||
} | ||
function commitDone(commitError, results) { | ||
var error = commitError || findErrorInResults(results) || null; | ||
if (error) { | ||
// Explicit ROLLBACK on failed COMMIT as per | ||
// https://www.sqlite.org/lang_transaction.html#response_to_errors_within_a_transaction | ||
self._db.exec(ROLLBACK, false, rollbackDone(error)); | ||
} else { | ||
done(); | ||
} | ||
} | ||
if (self._currentTask.readOnly) { | ||
done(); // read-only doesn't require a transaction | ||
done(err); // read-only doesn't require a transaction | ||
} else if (err) { | ||
self._db.exec(ROLLBACK, false, done); | ||
self._db.exec(ROLLBACK, false, rollbackDone(err)); | ||
} else { | ||
self._db.exec(COMMIT, false, done); | ||
self._db.exec(COMMIT, false, commitDone); | ||
} | ||
@@ -66,0 +84,0 @@ }; |
{ | ||
"name": "websql", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "WebSQL Database API, implemented for Node using sqlite3", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32991
352