Skip to content

glue::single_quote does not handle NA #135

@colearendt

Description

@colearendt

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions