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
#183: Error handling for the connection object being made before start_db_capturing() #186
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, thank you so much for this PR. It's a really great approach, and I like the detailed and helpful message.
- Do you like the error message? If not, what would you like it to show? Would you prefer sentences over the bullets? I am open to your preference :)
I like the details there and that the message is actionable. So far I haven't used rlang::abort()
in dittodb, but that is probably more old fashioned than it needs to be these days! I'm ok keeping rlang::abort
here, I've also added #187 to track possibly using it elsewhere to be consistent.
- I am not sure what needs to be added to clear out those warning messages
- If you know how to silence these warnings let me know!
Hmm, that is funny — have you looked in the DBI source to see if that's where the message is coming from? That might help identify how to silence it. Though to be honest they might be fine there — it's an error condition, and hopefully folks would read the error and not the warning.
- The dplyr::tbl(con, dbplyr::in_schema("dbo", "iris")) bit produces two error messages,
- I am not sure how to confront that or if its fine as is
This is coming from https://github.com/tidyverse/dbplyr/blob/0739c751e63b1aca17812e3f2db2640857e46043/R/db-sql.R#L1166-L1178 in dbplyr. I don't think there's much we can do about that, but I suspect that's fine since our message is right there and clear about what's going on.
- Any other guidelines you have that I missed let me know!
Have you thought about adding a test for this? You might add it to https://github.com/ropensci/dittodb/blob/main/tests/testthat/test-a-recording.R which has examples of recording a sqlite connection successfully, so we could do the wrong way around and confirm there's an error. It could also go in https://github.com/ropensci/dittodb/blob/main/tests/testthat/test-capture-requests.R which has other tests for capture-requests.R
.
Functionize db_path checker. Remove checks from functions that did not need them.
leaving a comment as a to-do to add unit tests seems like the fixes i added broke some unit tests. i will look into those as soon as i can 👍 |
can i get some assistance on passing testthat 2e tests? |
Aaaah, yes! I'm pretty sure what's going on there is that 2e swallows all but the last (or first? I can't remember) error / warning there. In order to deal with this there's a small helper Here is an example of that (where I assert the content of a message, but error should be the same) dittodb/tests/testthat/test-use-dittodb.R Lines 71 to 74 in 4ada9c9
Try that out and see if that resolves the 2e tests. Also, would it be possible to add in parts of the expected error messages there? Like I do with the message, just a part of the error is totally fine, but good to ensure we're getting the error(s) we expect there. For the 2e version, I usually have to run the test, see which one is bubbling up and using that. |
@jonkeane yippeee! thanks for the help, let me know if you had any other items you would like updated/implemented :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for pushing on this more!
I have ~one substantive suggestion which is basically: let's simplify check_db_path()
to always produce the detailed error even if it means more lines of error when people run into this. And then some small test changes to adjust to that.
Other than that it's minor style things that the linter is complaining about. I believe you can run styler::style_pkg()
and it will fix everything, but I know some times there are small and subtle things that the styler doesn't get just right. If this is frustrating, let me know and I'm happy to fix things up and push to the branch.
And again, thank you for your effort on this 💯
I have resolved all of the comments you left :) I seem to be facing a different set of errors now. Apologizing for not knowing how to address these solo, can I get some assistance, so I know how to address these? |
Sorry for my delay here! The failures you're seeing are actually coming from a dbplyr update. I just fixed those in I'll take a look at the changes themselves, but wanted to get this to you ASAP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small request. LMK if you're having trouble with getting the main update in and working.
Thanks again for this
@jonkeane i think were set for a final pass, let me know if you want a version bump or NEWS update :) |
That looks great — a news item would be lovely (sorry, should have asked for that in my last comment) and then I'll merge this (+start the process to release to CRAN to avoid too much difference with that dbplyr change) |
|
Thank you! |
This is for issue #183
I created a local postgres database to test this out more. I added an
rlang::abort
call to the send query bit. This seems to be a common function that a lot of the DBI functions use such asdbListTables
,dbListFields
, anddbExistsTable
. They also face a similar error. The screen shot is the PR minus the null checks on the 3 db functions:You can see they print the dbSendQuery abort message along with the error "Error in if (nzchar(file)) { : argument is of length zero". I added in a similar check to those 3 functions so they return NULL, which will make the dbSendQuery error print
Few things:
dplyr::tbl(con, dbplyr::in_schema("dbo", "iris"))
bit produces two error messages, I am not sure how to confront that or if its fine as isReprex for when you are developing within dittodb: