-
Notifications
You must be signed in to change notification settings - Fork 179
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
No TRUE literal in SQL Server, should escape()
default to list(clause = "SELECT")
?
#934
Comments
Do you have a specific use case? |
My use case is table ingestion in dm. When this is fixed, users could also do library(dbplyr)
con <- simulate_mssql()
# This is what dm needs:
escape(c(TRUE, FALSE), parens = FALSE, collapse = NULL, con = con)
#> <SQL> 1
#> <SQL> 0 |
There's a bit of description about the problem in https://dbplyr.tidyverse.org/reference/backend-mssql.html#bit-vs-boolean Currently we have https://github.com/tidyverse/dbplyr/blob/main/R/backend-mssql.R#L509-L517 And I think you're suggesting it should just be: #' @export
`sql_escape_logical.Microsoft SQL Server` <- function(con, x) {
y <- ifelse(x, "1", "0")
y[is.na(x)] <- "NULL"
y
} I think would be a safe change since you shouldn't be doing (e.g.) |
Perhaps shorter: #' @export
`sql_escape_logical.Microsoft SQL Server` <- function(con, x) {
if_else(x, "1", "0", "NULL")
} I don't see any situation where the current behavior is correct, it might be safe to change. |
Want to do a PR? |
MSSQL has no
TRUE
literal, but it's returned from translations: https://stackoverflow.com/a/7171264/946850.dm uses a home-grown routine to insert records into MS SQL Server, via
dbplyr::escape()
. This breaks with dbplyr >= 2.2.0.The reprex illustrates the problem. What's a good solution?
Created on 2022-07-06 by the reprex package (v2.0.1)
CC @TSchiefer.
The text was updated successfully, but these errors were encountered: