glue icon indicating copy to clipboard operation
glue copied to clipboard

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

Open mmuurr opened this issue 3 years ago • 0 comments

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

mmuurr avatar Jul 10 '22 23:07 mmuurr