Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExecuteTransaction with values throws exception for statements performing no actual changes #544

Closed
rastafan opened this issue Apr 21, 2024 · 5 comments

Comments

@rastafan
Copy link

Hi,

i noticed that executing statements such as DELETE or UPDATE which results in no rows changed, causes the plugin to throw an exception.

As an example, this is the case of DELETE operations on empty tables, or using conditions that results in no rows deleted.

This happens when using executeTransaction and passing parameters along with the statement:

this._db.executeTransaction([
    {
        statement: 'DELETE FROM some_table WHERE some_column = ?',
        values: [2]
     },
    {
        statement: 'DELETE FROM some_other_table WHERE some_other_column = ?',
        values: [3]
     }
])

this causes the plugin to use the run method internally.
The returned number of changes is 0, which seems right, but 0 is treated as an error condition and an exception is thrown.
This behavior is different from the "execute" part of this code, which is uses when no values are passed, and does not treat the "0 changes" condition as an error state.

The piece of internal code i'm referring to is this one: LINK

I would make a PR for this, but i'm not able to understand if there is a condition where it returns changes=0 upon some sort of error.

If anyone can help me test it (or can test it in my place) please let me know, so i can make a PR for this.

Thank you very much.

@jepiqueau
Copy link
Collaborator

@rastafan which platform?

@rastafan
Copy link
Author

tried only on web platform, still to test on android/ios

@jepiqueau
Copy link
Collaborator

@rastafan you right there is no reason to sent an error if changes is equal to 0. i will fix it in the next release

@rastafan
Copy link
Author

Alright, thank you very much!!

jepiqueau added a commit that referenced this issue Apr 28, 2024
@jepiqueau
Copy link
Collaborator

@rastafan fixed in v5.7.3-3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants