Skip to content

Commit

Permalink
add databaseConnectorTranslate option to allow users to globally turn…
Browse files Browse the repository at this point in the history
… off the DBI SQL translation.
  • Loading branch information
ablack3 committed Dec 12, 2023
1 parent 89a6093 commit efc8d77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/DBI.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit efc8d77

Please sign in to comment.