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_sql : quote integer if NA in the column #130

Closed
philibe opened this issue Mar 21, 2019 · 0 comments
Closed

glue_sql : quote integer if NA in the column #130

philibe opened this issue Mar 21, 2019 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@philibe
Copy link

philibe commented Mar 21, 2019

It's a little the next of #115 : When I have an Integer with NA in same column, I get the integer with quote.

However it's casted by my SGBDR.
When I replace .con = DBI::ANSI() by my SQL Server connection I have the same bug.

library(glue)

glue_sql(
  "{Col_int}",
  Col_int = data.frame(
    Col_int = c(1L, NA_integer_),
    stringsAsFactors = FALSE
  )$Col_int,
  .con = DBI::ANSI()
)
#> <SQL> '1'
#> <SQL> NULL


glue_sql(
  "{Col_int}",
  Col_int = as.numeric(data.frame(
    Col_int = c(1L, NA_integer_),
    stringsAsFactors = FALSE
  )$Col_int),
  .con = DBI::ANSI()
)
#> <SQL> '1'
#> <SQL> NULL

glue_sql(
  "{Col_int}",
  Col_int = as.numeric(data.frame(
    Col_int = c(1, 2),
    stringsAsFactors = FALSE
  )$Col_int),
  .con = DBI::ANSI()
)
#> <SQL> 1
#> <SQL> 2
sessionInfo() with glue 1.31

#> R version 3.4.4 (2018-03-15)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 16.04.4 LTS
#> 
#> Matrix products: default
#> BLAS: /usr/lib/libblas/libblas.so.3.6.0
#> LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] glue_1.3.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_3.4.4  backports_1.1.2 magrittr_1.5    rprojroot_1.3-2
#>  [5] DBI_1.0.0       tools_3.4.4     htmltools_0.3.6 yaml_2.2.0     
#>  [9] Rcpp_1.0.0      stringi_1.2.2   rmarkdown_1.9   knitr_1.20     
#> [13] stringr_1.3.1   digest_0.6.18   evaluate_0.11
Created on 2019-03-21 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants