-
Notifications
You must be signed in to change notification settings - Fork 174
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
filter generates buggy SQL when comparing with list element #1368
Labels
bug
an unexpected problem or unintended behavior
func trans 🌍
Translation of individual functions to SQL
Comments
Hmmmm, it looks like we're looking up library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
lf <- lazy_frame(a_id = 1, a_value = "value 1")
id <- 10000
l <- list(id = 1)
lf |> filter(a_id == l$id)
#> <SQL>
#> SELECT `df`.*
#> FROM `df`
#> WHERE (`a_id` = (1.0 AS `id`).10000.0) Created on 2023-11-02 with reprex v2.0.2 You can work around the problem by explicitly requesting local computation: library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
lf <- lazy_frame(a_id = 1, a_value = "value 1")
l <- list(id = 1)
lf |> filter(a_id == local(l$id))
#> <SQL>
#> SELECT `df`.*
#> FROM `df`
#> WHERE (`a_id` = 1.0) Created on 2023-11-02 with reprex v2.0.2 |
hadley
added
bug
an unexpected problem or unintended behavior
func trans 🌍
Translation of individual functions to SQL
labels
Nov 2, 2023
Merged
hadley
added a commit
that referenced
this issue
Feb 14, 2024
hadley
added a commit
that referenced
this issue
Feb 22, 2024
Partially reverts #1368. See bcgov/bcdata#338 for details. If we do this again in the future, I think we have to do argument checking in individual translations. That's a lot of work but allows a whole suite of potentially useful translations for more complex R objects.
hadley
added a commit
that referenced
this issue
Feb 28, 2024
Revert to previous escaping method (i.e. reverts #1368). See bcgov/bcdata#338 for details. If we do this again in the future, I think we have to do argument checking in individual translations. That's a lot of work but allows a whole suite of potentially useful translations for more complex R objects.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
an unexpected problem or unintended behavior
func trans 🌍
Translation of individual functions to SQL
When using tbl via dbplyr, filter generates correct SQL when comparing a column with an R scalar variable, but when using $ syntax to access value in a list, buggy sql is generated. The reprex below produces errors both with Postgres and SQLite connections, though more of the generated SQL is visible with Postgres
Something is wrong with the SQL quoting in this case.
The text was updated successfully, but these errors were encountered: