You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get transactions to work using this library, but some reason rollback is not working. My expectation is that if any statement in the transaction failed, the whole transaction should be rollbacked. Instead it appears to commit all statements except the failed one.
Below is my test code. Any idea what might be the issue?
constqueries=[{sql: `DROP TABLE IF EXISTS testing`,params: [],},{sql: ` CREATE TABLE testing ( id TEXT PRIMARY KEY, title TEXT NOT NULL DEFAULT "" )`,params: [],},{sql: `INSERT INTO testing (id, title) VALUES (?, ?)`,params: ["1","one"],},{sql: `INSERT INTO doesnotexist (id, title) VALUES (?, ?)`,params: ["2","two"],},]try{awaitdb.transaction(tx=>{for(constqueryofqueries){tx.executeSql(query.sql,query.params);}});}catch(error){console.error('SQL error:',error);}constresult=awaitdb.executeSql('SELECT * FROM testing');// Displays "["1", "one"]", which shows that the transaction was not rollbacked:console.info('RESULT:',result[0].rows.item(0));
The text was updated successfully, but these errors were encountered:
I just tested and I confirm transaction are not rollback on Android (it work fine on iOS).
I've created a fork of this repository that bring multiple things:
Fix this issue
Add UUID support
Update SQLite version to 3.43.1 (release on 2023-09-11)
Bring same version of SQLite for iOS & Android, independent of OS version (this mean SQLite is also compiled for iOS)
I hope that this fork will become the new reference for using SQLite with react native and will be regularly updated.
Do you have any idea of how to address this issue ? Or, alternatively, a direction in which to look for a solution (in which file it happens, for example) ? If possible I would be glad to add a fix in the fork.
I'm trying to get transactions to work using this library, but some reason rollback is not working. My expectation is that if any statement in the transaction failed, the whole transaction should be rollbacked. Instead it appears to commit all statements except the failed one.
Below is my test code. Any idea what might be the issue?
The text was updated successfully, but these errors were encountered: