I'm using Apache Cordova which is a Hybrid mobile application platform. I'm using the following plugin cordova-sqlite-storage for handling my SQLite. The syntax is completely identical to that of WebSQL.
Considering this is used with AngularJS I have my database set up in a factory, here is how I've always called a query to be ran against my database without any problems:
query: function(query, params, callback) {
try {
factory.database.transaction(function(tx) {
if(callback) tx.executeSql(query, params, callback, function(transaction, error) { console.log("ERROR"); });
else tx.executeSql(query,params);
});
} catch (e) {
console.log("ERROR: ", JSON.stringify(e));
}
}
However today, everything changed. Please note the "ERROR" callback is usually not present, however in this case it does not fire anyway.
So my issues are as follows:
- The Query does not execute, or so I believe, because the application hangs at this point.
- The Query does not fire the failed or success callbacks.
- The catch block is fired with a very uninformative error. (Atleast to myself).
The error displayed is as follows:
ERROR: , {"line":29,"column":21,"sourceURL":"http://ift.tt/22Jh6T5"}
For anyone curious about the scheme here are the following..
Table
tx.executeSql("CREATE TABLE IF NOT EXISTS messages (message_id INTEGER PRIMARY KEY, content VARCHAR NOT NULL, message_to INTEGER NOT NULL, message_from INTEGER NOT NULL, message_sent INTEGER, message_inserted INTEGER, message_type INTEGER DEFAULT (0));");
Insert Query
"INSERT INTO messages (message_id, content, message_to, message_from, message_sent, message_inserted) VALUES (?, ?, ?, ?, ?, ?);"
Insert parameters
[message.id, message.content, message.to, message.from, message.time, Math.floor(new Date().getTime() / 1000)]
I've verified that all of the parameters are correct, and use the correct format for the table. None of them are undefined or null.
The fact that this issue is throwing in the try/catch block is bothering me, and the error is very, very confusing.
Aucun commentaire:
Enregistrer un commentaire