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

compute() breaks schemas in dbplyr 2.2.0 #938

Closed
baileych opened this issue Jul 12, 2022 · 0 comments · Fixed by #941
Closed

compute() breaks schemas in dbplyr 2.2.0 #938

baileych opened this issue Jul 12, 2022 · 0 comments · Fixed by #941

Comments

@baileych
Copy link

baileych commented Jul 12, 2022

The addition of an unconditional call to unname() in compute.tbl_sql() added in #793 breaks use of schemas and catalogs, since both dbplyr::in_schema() and dbplyr::in_catalog() rely on names to identify the parts of the table identifier. Once the names are removed, a schema-qualified table name always renders as "NULL.NULL" (and similarly for catalog-schema-qualified tables).

require(dplyr)
require(RSQLite)
db <- DBI::dbConnect(SQLite(), ':memory:')
schematized <- dbplyr::in_schema('test', 'this')
# Create a table to select and compute
mtcars %>% slice_head(n = 5) %>% copy_to(db, ., name = 'this')
thistbl <- tbl(db, 'this')
#Bang
thistbl %>% compute(name = schematized)

yields Error: near "NULL": syntax error

A minimal fix would be to preserve names in cases we know they'll be needed:

 if (!any(class(name) %in% c('dbplyr_schema', 'dbplyr_catalog'))) name <- unname(name)
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 a pull request may close this issue.

1 participant