-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
translate_sql, as.character in combination with %in% #3205
Comments
Thanks, confirmed. I'm seeing on PostgreSQL:
Seems we need to adapt it there, too (at least). |
Hi @jessekps / @krlmlr - I don't see a way for Having said that, there is a way to make sure that the R function is evaluated prior sending it to the query, and that's by using library(RSQLite)
library(dbplyr)
library(rlang)
db <- dbConnect(SQLite(), ':memory:')
translate_sql(booklet_id %in% !! as.character(1:4), con=db )
#> <SQL> `booklet_id` IN ('1', '2', '3', '4')
dbDisconnect(db) |
Ok, thanks for looking into it anyway, much appreciated. I know about the Currently I'm fixing the translate_sql output with regular expressions. It works fine for my package but it's not a structural solution you would want I expect. |
This is currently out of scope for dbplyr sql translation. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
dbplyr
version 1.1.0
If I use %in% in combination with as.character, translate_sql generates SQL that is not valid for sqlite
In postgres and possibly other dbms this would be accepted but not in sqlite where it should be:
"booklet_id" IN( CAST(1 AS TEXT), CAST(2 AS TEXT), CAST(3 AS TEXT), CAST(4 AS TEXT))
(running it through partial_eval and translate_sql_ gives the exact same problem)
Thanks for the very nice package by the way!
The text was updated successfully, but these errors were encountered: