From 3422ef10cc3feb7bd464193e65df2223c400dc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 1 Apr 2024 18:58:04 +0200 Subject: [PATCH] fix: `dbQuoteLiteral()` uses exponential notation for numeric values --- R/dbQuoteLiteral_DBIConnection.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/dbQuoteLiteral_DBIConnection.R b/R/dbQuoteLiteral_DBIConnection.R index eb1760a2e..bc01d6a8d 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(x, names = names(x))) + } + if (is.logical(x)) { - x <- as.numeric(x) + x <- as.integer(x) } x <- as.character(x)