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

dbplyr doesn't parse lists correctly #291

Closed
tarunn90 opened this issue Apr 30, 2019 · 1 comment
Closed

dbplyr doesn't parse lists correctly #291

tarunn90 opened this issue Apr 30, 2019 · 1 comment

Comments

@tarunn90
Copy link

dbplyr doesn't parse arguments correctly when they're passed in through lists or other classes:

library(dplyr)
library(dbplyr)
library(DBI)
df <- data.frame(x = c(5, 5, 6))
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(conn = con, name = 'df', value = df, overwrite = T)
tbl(con, "df") %>% filter(x == 5) # this works
l <- list(y = 5)
tbl(con, "df") %>% filter(x == l$y) # errors
tbl(con, "df") %>% filter(x == l[['y']]) # errors
@hadley
Copy link
Member

hadley commented Apr 30, 2019

If you want to include use a local list, you need to unquote it.

library(dbplyr)
library(dplyr, warn.conflicts = FALSE)

df <- lazy_frame(x = c(5, 5, 6))
l <- list(y = 5)

df %>% filter(x == l$y)
#> <SQL>
#> SELECT *
#> FROM `df`
#> WHERE (`x` = (5.0 AS `y`).`y`)
df %>% filter(x == !!l$y)
#> <SQL>
#> SELECT *
#> FROM `df`
#> WHERE (`x` = 5.0)

Created on 2019-04-30 by the reprex package (v0.2.1.9000)

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

No branches or pull requests

2 participants