Skip to content

Commit f87cee1

Browse files
Fix insertWithOnConflict in SQLiteDatabase
This change checks the sqlite3_changes following execution of the insert statement. If no changes were made, we return -1, otherwise we return the last row id from the database.
1 parent af5f07f commit f87cee1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ public long insertWithOnConflict(String table, String nullColumnHack,
20262026
// Run the program and then cleanup
20272027
statement.execute();
20282028

2029-
long insertedRowId = lastInsertRow();
2029+
long insertedRowId = lastChangeCount() > 0 ? lastInsertRow() : -1;
20302030
if (insertedRowId == -1) {
20312031
Log.e(TAG, "Error inserting <redacted values> using <redacted sql> into " + table);
20322032
} else {

0 commit comments

Comments
 (0)