From 0cf15f40dfc0fb8ec9e04d2d0bf8191292a1bcf3 Mon Sep 17 00:00:00 2001 From: "Matthew D. Pagel" Date: Thu, 19 Dec 2024 12:04:52 -0500 Subject: [PATCH 1/2] add noSplit option to executeSql this allows for multi-statement execution at once for non-oracle DBMSes and/or for pre-split content. --- R/Sql.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/Sql.R b/R/Sql.R index 7453de77..0577d526 100644 --- a/R/Sql.R +++ b/R/Sql.R @@ -396,7 +396,8 @@ executeSql <- function(connection, progressBar = !as.logical(Sys.getenv("TESTTHAT", unset = FALSE)), reportOverallTime = TRUE, errorReportFile = file.path(getwd(), "errorReportSql.txt"), - runAsBatch = FALSE) { + runAsBatch = FALSE, + noSplit = FALSE) { if (inherits(connection, "DatabaseConnectorJdbcConnection") && rJava::is.jnull(connection@jConnection)) { abort("Connection is closed") } @@ -414,7 +415,11 @@ executeSql <- function(connection, } batched <- runAsBatch && supportsBatchUpdates(connection) - sqlStatements <- SqlRender::splitSql(sql) + if (noSplit) { # can prob. replace this block with `sqlStatements <- ifelse(noSplit, sql ,SqlRender::splitSql(sql))` + sqlStatements <- sql + } else { + sqlStatements <- SqlRender::splitSql(sql) + } rowsAffected <- c() if (batched) { batchSize <- 1000 From c16ec798c673660637ae663a84a96256f38373fe Mon Sep 17 00:00:00 2001 From: "Matthew D. Pagel" Date: Thu, 19 Dec 2024 12:13:59 -0500 Subject: [PATCH 2/2] Update Sql.R vectorize --- R/Sql.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/Sql.R b/R/Sql.R index 0577d526..5addb3f4 100644 --- a/R/Sql.R +++ b/R/Sql.R @@ -415,8 +415,8 @@ executeSql <- function(connection, } batched <- runAsBatch && supportsBatchUpdates(connection) - if (noSplit) { # can prob. replace this block with `sqlStatements <- ifelse(noSplit, sql ,SqlRender::splitSql(sql))` - sqlStatements <- sql + if (noSplit) { # can prob. replace this block with `sqlStatements <- ifelse(noSplit, unlist(sql) ,SqlRender::splitSql(sql))` + sqlStatements <- unlist(sql) # splitSql outputs a vector of character stings, so we should do the same } else { sqlStatements <- SqlRender::splitSql(sql) }