Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Fixed runInTransaction in absurd sql adapter #70

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

kevin-dp
Copy link
Contributor

The adapter for absurd sql was executing an "ABORT" statement when a query failed.
However, "ABORT" does not exist in SQLite, it is called "ROLLBACK".
I fixed this and throw the error such that the promise is rejected with the reason why the transaction was rolled back.

Copy link
Contributor

@balegas balegas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, that was some pretty bad code. Thanks for fixing it.

@kevin-dp
Copy link
Contributor Author

kevin-dp commented Feb 1, 2023

If the table does not define a conflict strategy (i.e. uses the default which is ON CONFLICT ABORT) then this will work.
However, if the table defines ON CONFLICT ROLLBACK then an error will automatically trigger the rollback so we should not call ROLLBACK ourselves because that will throw an error. We could wrap our call to "ROLLBACK" with a try catch and on catch just ignore it (since that means the rollback already happened).

@kevin-dp kevin-dp merged commit 8f8ae40 into main Feb 2, 2023
@kevin-dp kevin-dp deleted the kevindp/absurd-sql-transaction-rollback branch February 2, 2023 09:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants