Skip to content

glue_sql converts length-0 vectors to NULL in asterisk-expansion #272

@mmuurr

Description

@mmuurr
x <- character(0)
glue::glue_sql("{x*}")
# <SQL> NULL

When used as part of an SQL expression, this can happen:

glue::glue_sql("select foo from bar where baz in ({x*})")
# <SQL> select foo from bar where baz in (NULL)

... which has different semantics (in most SQL variants) than what I believe most users likely are intending when x is empty:

# <SQL> select foo from bar where baz in ()  <-- the _intended_ SQL, I think.

I've confirmed this also happens with DB object identified expansion, too, i.e.:

"{`x`*}"
# <SQL> NULL

Metadata

Metadata

Assignees

No one assigned

    Labels

    SQL 🛢️bugan unexpected problem or unintended behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions