diff --git a/R/dbQuoteLiteral_DBIConnection.R b/R/dbQuoteLiteral_DBIConnection.R index eb1760a2e..c79a04bc3 100644 --- a/R/dbQuoteLiteral_DBIConnection.R +++ b/R/dbQuoteLiteral_DBIConnection.R @@ -48,8 +48,14 @@ dbQuoteLiteral_DBIConnection <- function(conn, x, ...) { return(SQL(blob_data, names = names(x))) } + if (is.double(x)) { + out <- sprintf("%.17e", x) + out[is.na(x)] <- "NULL" + return(SQL(out, names = names(x))) + } + if (is.logical(x)) { - x <- as.numeric(x) + x <- as.integer(x) } x <- as.character(x) diff --git a/tests/testthat/test-sql-df.R b/tests/testthat/test-sql-df.R index 042ff36b4..4dafd61c4 100644 --- a/tests/testthat/test-sql-df.R +++ b/tests/testthat/test-sql-df.R @@ -6,6 +6,6 @@ test_that("NAs turn in NULLs", { ) sql_df <- sqlData(ANSI(), df) - expect_equal(sql_df$x, SQL(c("1", "NULL"))) + expect_equal(sql_df$x, SQL(c("1.00000000000000000e+00", "NULL"))) expect_equal(sql_df$y, SQL(c("'a'", "NULL"))) })