From efc8d77f85b977785aef99503dbe790096eb31b6 Mon Sep 17 00:00:00 2001 From: Adam Black Date: Tue, 12 Dec 2023 10:47:57 +0100 Subject: [PATCH] add databaseConnectorTranslate option to allow users to globally turn off the DBI SQL translation. --- R/DBI.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/DBI.R b/R/DBI.R index 6cb13635..a09313d1 100644 --- a/R/DBI.R +++ b/R/DBI.R @@ -208,7 +208,7 @@ setClass("DatabaseConnectorDbiResult", setMethod( "dbSendQuery", signature("DatabaseConnectorJdbcConnection", "character"), - function(conn, statement, translate = FALSE, ...) { + function(conn, statement, translate = getOption("databaseConnectorTranslate", default = TRUE), ...) { if (rJava::is.jnull(conn@jConnection)) { abort("Connection is closed") } @@ -258,7 +258,7 @@ setMethod( setMethod( "dbSendQuery", signature("DatabaseConnectorDbiConnection", "character"), - function(conn, statement, translate = FALSE, ...) { + function(conn, statement, translate = getOption("databaseConnectorTranslate", default = TRUE), ...) { if (translate) { statement <- translateStatement( sql = statement, @@ -426,7 +426,7 @@ setMethod("dbGetRowsAffected", "DatabaseConnectorDbiResult", function(res, ...) setMethod( "dbGetQuery", signature("DatabaseConnectorConnection", "character"), - function(conn, statement, translate = FALSE, ...) { + function(conn, statement, translate = getOption("databaseConnectorTranslate", default = TRUE), ...) { if (translate) { statement <- translateStatement( sql = statement, @@ -447,7 +447,7 @@ setMethod( setMethod( "dbSendStatement", signature("DatabaseConnectorConnection", "character"), - function(conn, statement, translate = FALSE, ...) { + function(conn, statement, translate = getOption("databaseConnectorTranslate", default = TRUE), ...) { if (translate) { statement <- translateStatement( sql = statement, @@ -472,7 +472,7 @@ setMethod( setMethod( "dbExecute", signature("DatabaseConnectorConnection", "character"), - function(conn, statement, translate = FALSE, ...) { + function(conn, statement, translate = getOption("databaseConnectorTranslate", default = TRUE), ...) { if (isDbplyrSql(statement) && dbms(conn) %in% c("oracle", "bigquery", "spark", "hive") && grepl("^UPDATE STATISTICS", statement)) { # These platforms don't support this, so SqlRender translates to an empty string, which causes errors down the line. return(0)