glue::glue() has a .na parameter that allows you to control how NA is treated.
I would argue that glue::single_quote(NA) should be NA or should at least be controllable. Honestly, in the use cases I was trying (generating SQL), either single_quote(NA) = NA or single_quote(NA) = '' made the most sense to me. "NA" feels weird in that it is neither single quoted nor a value consistent with the nature of NA.
var <- NA
glue::single_quote(glue::glue("hello {NA}", .na = ""))
#> [1] "'hello '"
glue::single_quote(glue::glue("hello {var}", .na = ""))
#> [1] "'hello '"
# my confusion rests here
glue::single_quote(NA)
#> [1] "NA"
glue::single_quote(NULL)
#> character(0)
Created on 2019-04-24 by the reprex package (v0.2.1)
glue::glue()has a.naparameter that allows you to control howNAis treated.I would argue that
glue::single_quote(NA)should beNAor should at least be controllable. Honestly, in the use cases I was trying (generating SQL), eithersingle_quote(NA) = NAorsingle_quote(NA) = ''made the most sense to me."NA"feels weird in that it is neither single quoted nor a value consistent with the nature of NA.Created on 2019-04-24 by the reprex package (v0.2.1)