Skip to content
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

glue::single_quote does not handle NA #135

Closed
colearendt opened this issue Apr 24, 2019 · 2 comments
Closed

glue::single_quote does not handle NA #135

colearendt opened this issue Apr 24, 2019 · 2 comments

Comments

@colearendt
Copy link

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)

@jimhester
Copy link
Collaborator

If you were generating SQL why were you not using glue_sql()?

But anyway I agree the behavior is not correct, will fix it so these all return a NA value.

@colearendt
Copy link
Author

Awesome, thanks! I don't really remember, to be honest 😬 I think I had a FR for glue_sql, but this is all I recorded. Next time I work on this project, I will definitely let you know if there is something other than ignorance of functionality that kept me from using glue_sql 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants