Skip to content

glue_sql() replaces all values with NULL when using * and vector has NA values #185

@carstenstann

Description

@carstenstann

Glue 1.4.0 converts a vector containing NA_character_ to NULL when using * to collapse values, whereas 1.3.2 left NAs in place.

With 1.3.2:

> glue_sql("SELECT A FROM B WHERE B IN ({values*});", values= c(NA, "A","M","Q"), .con=dbConnect(RSQLite::SQLite(), ""))
<SQL> SELECT A FROM B WHERE B IN (NULL, 'A', 'M', 'Q');

With 1.4.0:

> library(glue)
> library(DBI)
> glue_sql("SELECT A FROM B WHERE B IN ({values*});", values= c(NA, "A","M","Q"), .con=dbConnect(RSQLite::SQLite(), ""))
<SQL> SELECT A FROM B WHERE B IN (NULL);
> 

This occurred for me on R 3.5.3 Platform x86_64-wmingw32/x64 as well as on R 3.6.3 (2020-02-29) Platform: x86_64-apple-darwin15.6.0 (64-bit)

Is this a bug? This seems related to #115 amd #130

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions