mirror of
https://github.com/moparisthebest/PhoneGap-SQLitePlugin-Android
synced 2024-11-13 12:35:09 -05:00
Fix #18/#38: insertId for INSERT reported for Android
This commit is contained in:
parent
6194a6b4fc
commit
7a93d8d849
@ -158,10 +158,19 @@ public class SQLitePlugin extends Plugin {
|
||||
query = queryarr[i];
|
||||
params = paramsarr[i];
|
||||
query_id = queryIDs[i];
|
||||
Cursor myCursor = this.myDb.rawQuery(query, params);
|
||||
|
||||
this.processResults(myCursor, query_id, tx_id);
|
||||
myCursor.close();
|
||||
if (query.toLowerCase().startsWith("insert")) {
|
||||
SQLiteStatement myStatement = this.myDb.compileStatement(query);
|
||||
long insertId = myStatement.executeInsert();
|
||||
|
||||
//String result = "[{'insertId':'" + insertId + "'}]";
|
||||
String result = "{'insertId':'" + insertId + "'}";
|
||||
this.sendJavascript("SQLitePluginTransaction.queryCompleteCallback('" + tx_id + "','" + query_id + "', " + result + ");");
|
||||
} else {
|
||||
Cursor myCursor = this.myDb.rawQuery(query, params);
|
||||
|
||||
this.processResults(myCursor, query_id, tx_id);
|
||||
myCursor.close();
|
||||
}
|
||||
}
|
||||
this.myDb.setTransactionSuccessful();
|
||||
}
|
||||
|
@ -206,8 +206,8 @@ Make a change like this to index.html to run a small test program to verify the
|
||||
+ tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');
|
||||
+
|
||||
+ tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) {
|
||||
+ console.log("insertId: " + res.insertId + " -- probably 1");
|
||||
+ alert("insertId: " + res.insertId + " -- should be valid"); // reproduce #18/#38
|
||||
+ console.log("insertId: " + res.insertId + " -- probably 1"); // check #18/#38 is fixed
|
||||
+ alert("insertId: " + res.insertId + " -- should be valid");
|
||||
+
|
||||
+ db.transaction(function(tx) {
|
||||
+ tx.executeSql("SELECT data_num from test_table;", [], function(tx, res) {
|
||||
|
Loading…
Reference in New Issue
Block a user