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

Improve validation #153

Merged
merged 13 commits into from
Jan 28, 2023
Merged

Improve validation #153

merged 13 commits into from
Jan 28, 2023

Conversation

hadley
Copy link
Member

@hadley hadley commented Jan 13, 2023

  • Correctly access pool metadata, respecting validateQuery and ensuring cache actually works.
  • Validate on creation to ensure problems are revealed as soon as possible.
  • Review and better comment validation query options.

Fixes #133

* Correctly access pool metadata, respecting `validateQuery` and ensuring cache actually works.
* Validate on creation to ensure problems are revealed as soon as possible.

Fixes #133
@hadley
Copy link
Member Author

hadley commented Jan 13, 2023

To do:

  • Figure out why tests are failing
  • Test this code (i.e. that validateQuery is correctly set, and correctly cached)
  • Extract helper for pool metadata attribute

@hadley hadley requested a review from jcheng5 January 13, 2023 19:12
R/DBI-pool.R Outdated Show resolved Hide resolved
@michaelbonilla
Copy link

When I reinstall the package and attempt to run dbPool(), I get the following error now:
Error in pool_metadata(object) : could not find function "pool_metadata"

Could that be because the pool_metadata() function was created within the testthat set of functions, not the standard R folder of funtions?

Forgive me if I'm wrong, I don't fully understand how testthat works within package development.

@hadley
Copy link
Member Author

hadley commented Jan 13, 2023

@michaelbonilla yeah that was just a dumb mistake on my behalf.

@michaelbonilla
Copy link

Everything works as expected for me again.

@michaelbonilla
Copy link

Is there any update on this? We are still waiting on this PR and the next release to CRAN before being able to update it in our Package Manager and use Pool in production.

@hadley
Copy link
Member Author

hadley commented Jan 26, 2023

@michaelbonilla just waiting for @jcheng5 to have some free time to review. I will see him in person next week so maybe I'll be able to force his eyeballs to look at this 😄

R/DBI-pool.R Outdated
@@ -24,7 +24,7 @@ setMethod("onDestroy", "DBIConnection", function(object) {
#' @export
#' @rdname object
setMethod("onValidate", "DBIConnection", function(object) {
pool <- attr(object, "..metadata", exact = TRUE)$pool
pool <- pool_metadata(object)$pool
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change that fixed the underlying problem: now we have a helper that ensures we're always accessing the correct attribute.

R/DBI-pool.R Outdated
"select count(*) from SYS_TABLES",
"select count(*) from SYS.TABLES"
# informix
"SELECT 1 FROM systables WHERE 0=1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced 0=1 to ensure query always runs quickly.

R/pool.R Outdated Show resolved Hide resolved
#Conflicts:
#	DESCRIPTION
#	NEWS.md
#	R/DBI-pool.R
#	R/pool.R
#	tests/testthat/_snaps/release.md
#	tests/testthat/test-release.R
@hadley hadley merged commit 879533b into main Jan 28, 2023
@hadley hadley deleted the validate-query branch January 28, 2023 23:33
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

Successfully merging this pull request may close these issues.

poolCheckout Causing Authentication Errors on DB2 Server
2 participants