dbplyr 1.4.0 appears to translate filter_at() calls incorrectly, translating the variable name themselves, rather than their values. See following example:
library(dplyr)
library(dbplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, mtcars)
mtcars2 <- tbl(con, "mtcars")
cols <- c("vs", "am", "gear", "carb")
nums <- c(4, 5)
num <- 1
test <- mtcars2 %>%
filter(gear %in% nums,
gear == num) %>%
filter_at(cols, any_vars(. %in% nums)) %>%
filter_at(cols, any_vars(. == num))
show_query(test)
In dbplyr 1.3.0 this gives the following SQL query:
SELECT *
FROM (SELECT *
FROM (SELECT *
FROM `mtcars`
WHERE ((`gear` IN (4.0, 5.0)) AND (`gear` = 1.0)))
WHERE (`vs` IN (4.0, 5.0) OR `am` IN (4.0, 5.0) OR `gear` IN (4.0, 5.0) OR `carb` IN (4.0, 5.0)))
WHERE (`vs` = 1.0 OR `am` = 1.0 OR `gear` = 1.0 OR `carb` = 1.0)
but in dbplyr 1.4.0 the variables are translated literally as "num" and "nums" in the SQL translation of the filter_at() function, although they are translated as expected from the filter() function.
SELECT *
FROM (SELECT *
FROM (SELECT *
FROM `mtcars`
WHERE ((`gear` IN (4.0, 5.0)) AND (`gear` = 1.0)))
WHERE (`vs` IN `nums` OR `am` IN `nums` OR `gear` IN `nums` OR `carb` IN `nums`))
WHERE (`vs` = `num` OR `am` = `num` OR `gear` = `num` OR `carb` = `num`)
This then leads to an error when querying the database via collect() as there are no num or nums variables on the database end.
dbplyr 1.4.0 appears to translate
filter_at()calls incorrectly, translating the variable name themselves, rather than their values. See following example:In dbplyr 1.3.0 this gives the following SQL query:
but in dbplyr 1.4.0 the variables are translated literally as "num" and "nums" in the SQL translation of the
filter_at()function, although they are translated as expected from thefilter()function.This then leads to an error when querying the database via
collect()as there are nonumornumsvariables on the database end.