From 3de1a5fea8eb3abefc4a53fd9985b7961c91361d Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 8 Apr 2024 16:21:27 -0500 Subject: [PATCH 1/2] check inputs for "ODBC configuration" --- R/connection-pane.R | 15 +++++++++++++++ R/odbc.R | 1 + 2 files changed, 16 insertions(+) diff --git a/R/connection-pane.R b/R/connection-pane.R index dd291b5c..f6ff7ff2 100644 --- a/R/connection-pane.R +++ b/R/connection-pane.R @@ -93,6 +93,11 @@ odbcListObjects.OdbcConnection <- function(connection, name = NULL, type = NULL, ...) { + check_string(catalog, allow_null = TRUE) + check_string(schema, allow_null = TRUE) + check_string(name, allow_null = TRUE) + check_string(type, allow_null = TRUE) + # if no catalog was supplied but this database has catalogs, return a list of # catalogs if (is.null(catalog)) { @@ -221,6 +226,10 @@ odbcListColumns.OdbcConnection <- function(connection, catalog = NULL, schema = NULL, ...) { + check_string(table, allow_null = TRUE) + check_string(view, allow_null = TRUE) + check_string(catalog, allow_null = TRUE) + check_string(schema, allow_null = TRUE) # specify schema or catalog if given cols <- odbcConnectionColumns_(connection, @@ -262,6 +271,12 @@ odbcPreviewObject.OdbcConnection <- function(connection, schema = NULL, catalog = NULL, ...) { + check_number_whole(rowLimit) + check_string(table, allow_null = TRUE) + check_string(view, allow_null = TRUE) + check_string(schema, allow_null = TRUE) + check_string(catalog, allow_null = TRUE) + # extract object name from arguments name <- validateObjectName(table, view, ...) diff --git a/R/odbc.R b/R/odbc.R index 55c51a86..ee6b64df 100644 --- a/R/odbc.R +++ b/R/odbc.R @@ -13,6 +13,7 @@ #' odbcSetTransactionIsolationLevel(con, "SQL_TXN_READ_UNCOMMITTED") #' } odbcSetTransactionIsolationLevel <- function(conn, levels) { + arg_match(levels, values = names(odbc:::transactionLevels()), multiple = TRUE) # Convert to lowercase, spaces to underscores, remove sql_txn prefix levels <- tolower(levels) levels <- gsub(" ", "_", levels) From e40243fe76f339ab5efd5537937740f76a6bc88e Mon Sep 17 00:00:00 2001 From: "Simon P. Couch" Date: Tue, 9 Apr 2024 09:26:52 -0500 Subject: [PATCH 2/2] apply suggestions from review Co-authored-by: Hadley Wickham --- R/odbc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/odbc.R b/R/odbc.R index ee6b64df..0c320b01 100644 --- a/R/odbc.R +++ b/R/odbc.R @@ -13,7 +13,7 @@ #' odbcSetTransactionIsolationLevel(con, "SQL_TXN_READ_UNCOMMITTED") #' } odbcSetTransactionIsolationLevel <- function(conn, levels) { - arg_match(levels, values = names(odbc:::transactionLevels()), multiple = TRUE) + arg_match(levels, values = names(transactionLevels()), multiple = TRUE) # Convert to lowercase, spaces to underscores, remove sql_txn prefix levels <- tolower(levels) levels <- gsub(" ", "_", levels)