I know the title is a mouthful but I honestly couldn't come up with a better one for my specific case (open to suggestions).
So basically I jotted down on this JSFiddle (a simplified version of) the issue I am facing. I am using AngularJS's $q.all
method to collect an array of promises dependent on query results:
db.transaction(function(tx) {
$q.all(fn(tx)).then(function(a) {
console.log("Result:", a);
});
});
where fn
is a function that returns an array of promises.
In the above case, everything works as expected and the result (the array of sql query results which resolve the promises) is console.log
ged correctly.
However, if I wrap $q.all
in the then
method of another deferred object, as so:
db.transaction(function(tx) {
fn2(tx).then(function(tx) {
$q.all(fn(tx)).then(function(a) {
console.log("Result:", a);
});
});
});
I get the error: Error: Failed to execute 'executeSql' on 'SQLTransaction': SQL execution is disallowed.
(fn2
is a function that merely returns a promise which resolves to the tx
object itself).
Have I stumbled upon a common pitfall? I searched about but haven't come up with anything. Cheers.