Skip to content

Expose 'random_table_name' as a tweak? #406

@MichaelChirico

Description

@MichaelChirico

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions