-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
I have some code where I'm building up complex conditions to insert into a parameterized query with glue_sql. In a previous glue version, if those conditions were NULL (in R) I would insert nothing into that part of the query using .null = DBI::SQL("")
in glue_sql. However, in 1.8.0 it appears that the .null argument no longer has any impact on the output of glue_sql, and the .na argument doesn't seem to do anything either.
Is this the intended behavior of these arguments?
library(glue)
library(DBI)
library(RSQLite)
con <- dbConnect(RSQLite::SQLite(), "test.sqlite")
# In previous glue version these would be equivalent, now first returns empty query
glue_sql("select {cond}", .con = con, .null = DBI::SQL(""), cond = NULL)
#> <SQL>
glue_sql("select {cond}", .con = con, cond = DBI::SQL(""))
#> <SQL> select
# And neither .null nor .na seem to have any effect on output
glue_sql("select {cond}", .con = con, .null = "foo", .na = "foo", cond = NA)
#> <SQL> select NULL
glue_sql("select {cond}", .con = con, .null = "foo", .na = "foo", cond = NULL)
#> <SQL>
Created on 2024-11-26 with reprex v2.1.1
Session info
sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 20.04.6 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3; LAPACK version 3.9.0
#>
#> locale:
#> [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
#> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
#> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] RSQLite_2.3.8 DBI_1.2.3 glue_1.8.0
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.37 fastmap_1.2.0 bit_4.5.0 xfun_0.49
#> [5] cachem_1.1.0 blob_1.2.4 knitr_1.49 memoise_2.0.1
#> [9] htmltools_0.5.8.1 bit64_4.5.2 rmarkdown_2.29 lifecycle_1.0.4
#> [13] cli_3.6.3 vctrs_0.6.5 reprex_2.1.1 withr_3.0.2
#> [17] compiler_4.4.2 rstudioapi_0.17.1 tools_4.4.2 evaluate_1.0.1
#> [21] yaml_2.3.10 rlang_1.1.4 fs_1.6.5
debdagybra
Metadata
Metadata
Assignees
Labels
No labels