I'm using Lawnchair as part of SroutCore application that makes several inserts into the store. Each subsequent inset doesn't wait until the first insert completes.
The behavior I'm observing is that the first transaction never completes in case a second transaction was started.
insert: function(obj, callback) {
var that = this;
console.log("Lawnchair.save.insert obj=%@".fmt(obj));
that.db.transaction(function(t) {
console.log("Lawnchair.save.insert.transaction t=%@ obj.key=%@".fmt(t, obj.key));
var id = (obj.key == undefined) ? that.uuid() : obj.key;
delete(obj.key);
console.log("SQL: INSERT INTO %@ (id, value,timestamp) VALUES (%@,%@,%@)".fmt(that.table, id, that.serialize(obj), that.now()));
t.executeSql(
"INSERT INTO " + that.table + " (id, value,timestamp) VALUES (?,?,?)",
[id, that.serialize(obj), that.now()],
function() {
console.log("executeSQL INSERT success on %@ calling callback %@".fmt(that.table, callback));
if (callback != undefined) {
obj.key = id;
that.terseToVerboseCallback(callback)(obj);
}
},
that.onError);
},
that.onError,
function() { console.log('INSERT: tx succeeded on table %@'.fmt(that.table));}
);
will not be called.
It doesn't seem to be an issue with Lawnchair logic per-se, more like a bug of Safari on iOS. But even so, it cripples Lawnchair in a big way.
As a fix, one option is to add a new adapter iOSWebkitSQLiteAdaptor that will queue the insert and update requests and execute them in a sequential/chained way.