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

Expose 'random_table_name' as a tweak? #406

Open
MichaelChirico opened this issue Mar 19, 2025 · 0 comments · May be fixed by #408
Open

Expose 'random_table_name' as a tweak? #406

MichaelChirico opened this issue Mar 19, 2025 · 0 comments · May be fixed by #408

Comments

@MichaelChirico
Copy link
Contributor

DBItest/R/utils.R

Lines 66 to 69 in f19fb4d

random_table_name <- function(n = 10) {
# FIXME: Use parallel-safe sequence of numbers
paste0("dbit", paste(sample(letters, n, replace = TRUE), collapse = ""))
}

For us, CREATE TABLE abcdefg is not allowed -- all tables must be qualified as part of a namespace.

We already have tweaks$create_table_as to handle this, but it does not cover all the places where CREATE TABLE statements are attempted, e.g.

fetch_no_return_value = function(con, table_name) {
#'
#' Calling `dbFetch()` on a result set from a data manipulation query
#' created by [dbSendStatement()] can
#' be fetched and return an empty data frame, with a warning.
query <- paste0("CREATE TABLE ", table_name, " (a integer)")
res <- local_result(dbSendStatement(con, query))
expect_warning(rows <- check_df(dbFetch(res)))
expect_identical(rows, data.frame())
},

I think having tweaks$random_table_name() instead would be a better/more general solution.

Does that sound right? How does one edit the set of tweaks, exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant