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

Fix DBI incompatibility by implementing a method for DBI::dbSendStatement() #105

Open
shearerpmm opened this issue Sep 14, 2023 · 0 comments

Comments

@shearerpmm
Copy link

shearerpmm commented Sep 14, 2023

Summary

RJDBC has an incompatibility with the DBI generic interface, which can be fixed by implementing a method for DBI::dbSendStatement() that calls RJDBC::dbSendUpdate(). I think this is a one-line fix.

Details

Since RJDBC is the JDBC backend for DBI, many packages call RJDBC through DBI generics. For example, dbplyr::compute(), which is designed to create tables, uses DBI::dbExecute() to send the table creation DML to the appropriate method. If a JDBC connection is used, it will ultimately ask RJDBC to execute the DML, as explained in this issue.

For data manipulation queries like creating tables, DBI::dbExecute() calls the generic DBI::dbSendStatement(). The DBI authors ask that database package developers include a method for this generic. If one doesn't exist, the default is to forward to dbSendQuery():

dbSendStatement() comes with a default implementation that simply forwards to dbSendQuery(), to support backends that only implement the latter.

The problem is that RJDBC::dbSendQuery() is not the right RJDBC method for creating tables. Per the documentation, RJDBC::dbSendUpdate() is the right method:

dbSendQuery and dbSendUpdate submit a SQL query to the database. The difference between the two is only that dbSendUpdate is used with DBML queries and thus doesn't return any result set.

If RJDBC implements a method for DBI::dbSendStatement() that calls RJDBC::dbSendUpdate(), then functions like dbplyr::compute() will work as intended instead of throwing an error.

@shearerpmm shearerpmm changed the title [Enhancement Request] Fix DBI incompatibility by implementing a method for DBI::dbSendStatement() Fix DBI incompatibility by implementing a method for DBI::dbSendStatement() Sep 14, 2023
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

1 participant