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

any-db-sqlite3: Delete query don't returns the affected rows #83

Open
juanluispaz opened this issue Feb 5, 2020 · 2 comments
Open

any-db-sqlite3: Delete query don't returns the affected rows #83

juanluispaz opened this issue Feb 5, 2020 · 2 comments

Comments

@juanluispaz
Copy link

When a delete query is executed using any-db-sqlite3, the number of affected rows (rowCount) is always 0 even when some rows was deleted in sqlite

@grncdr
Copy link
Owner

grncdr commented Feb 12, 2020

I think this is because the adapter is using eachQuery instead of runQuery for delete queries. Appending RETURNING 1 to your query might be viable workaround.

@juanluispaz
Copy link
Author

Reading the code I found:

In the file packages/any-db-sqlite3/index.js line 75:

  if (query.text.match(/^\s*(insert|update|replace)\s+/i)) {
    runQuery(this._db, query)
  } else {
    eachQuery(this._db, query)
  }

The thing is delete is missing in the regex in order to call the correct implementation.

runQuery includes in the result the number of affected rows, but eachQuery not.

Note: Sqlite doesn't support returning

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