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

dbExecute returns the last value when executing drop table #238

Closed
digitalwright opened this issue Oct 23, 2017 · 2 comments
Closed

dbExecute returns the last value when executing drop table #238

digitalwright opened this issue Oct 23, 2017 · 2 comments

Comments

@digitalwright
Copy link

According to the documentation, dbExecute() is supposed to return the "number of rows affected by the statement". This tends to work, but it appears that when dropping a table dbExecute() instead returns the number of rows affected by the last call to dbExecute(). If no previous statements were executed then it returns 1 row affected independent of the number of rows in the table that was dropped.

con <- dbConnect(RSQLite::SQLite(), ":memory:")

data(USArrests)
dim(USArrests) # 50 rows

dbWriteTable(con, "USArrests", USArrests)

dbExecute(con, "delete from USArrests where UrbanPop < 50") # 8 rows deleted

dbExecute(con, "drop table USArrests") # 8 rows affected?

dbDisconnect(con)

This was on RSQlite v2.0.

@krlmlr
Copy link
Member

krlmlr commented Dec 9, 2017

Thanks, confirmed.

@krlmlr krlmlr closed this as completed in 11cb97e Dec 9, 2017
krlmlr added a commit that referenced this issue Mar 25, 2018
- Values of class `"integer64"` are now supported for `dbWriteTable()` and `dbBind()` (#243).
- New connections now automatically load default RSQLite extensions (#236).
- Implement `dbUnquoteIdentifier()`.
- Update bundled sqlite3 library to 3.22 (#252).
- Names in the `x` argument to `dbQuoteIdentifier()` are preserved in the output (r-lib/DBI#173).
- Fix rchk warnings on CRAN (#250).
- `dbRowsAffected()` and `dbExecute()` return zero after a `DROP TABLE` statement, and not the number of rows affected by the last `INSERT`, `UPDATE`, or `DELETE` (#238).
- Refactor connection and result handling to be more similar to other backends.
- Fix `dbQuoteIdentifier()` to ignore invalid UTF-8 strings (r-dbi/DBItest#156).
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants