Skip to content

Commit a702fe0

Browse files
author
Stefan Fleck
committed
internal renames and fixed one DBI test so that it also works with RJDBC
1 parent 770e7d3 commit a702fe0

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

R/Layout.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ LayoutDbi <- R6::R6Class(
399399
!is.null(private$.col_types),
400400
"To create new database tables the Layout must contain `col_types`"
401401
)
402-
generate_sql_create_table(
402+
sql_create_table(
403403
tname = table,
404404
col_types = private$.col_types,
405405
col_names = names(private$.col_types)

R/utils.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ ptrunc_col <- function(
125125
#' @noRd
126126
#'
127127
#' @examples
128-
#' generate_sql_create_table(
128+
#' sql_create_table(
129129
#' "example.table",
130130
#' c("numbers", "animals"),
131131
#' c("integer", "varchar(8)"),
132132
#' c("NOT NULL", "")
133133
#' )
134-
generate_sql_create_table <- function(
134+
sql_create_table <- function(
135135
tname,
136136
col_names,
137137
col_types,

man/Logger.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_AppenderDbi.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ dbs <- list(
7070
options("datatable.showProgress" = dt_sp)
7171

7272
nm <- "SQLite via RSQLite" # for manual testing, can be deleted
73-
nm <- "PostgreSQL via RPostgreSQL" # for manual testing, can be deleted
73+
nm <- "DB2 via RJDBC" # for manual testing, can be deleted
7474

7575

7676

@@ -252,7 +252,12 @@ for (nm in names(dbs)){
252252

253253
# cleanup
254254
expect_true(
255-
DBI::dbRemoveTable(conn, lg$appenders$db$layout$format_table_name("LOGGING_TEST_BUFFER"))
255+
x <- tryCatch({
256+
r <- DBI::dbRemoveTable(conn, lg$appenders$db$layout$format_table_name("LOGGING_TEST_BUFFER"))
257+
if (!length(r)) TRUE else r # for RJDBC
258+
},
259+
error = function(e) FALSE # for RJDBC
260+
)
256261
)
257262
})
258263

tests/testthat/test_utils.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,28 +107,28 @@ test_that("generate_sql works as expected", {
107107
"GRAPHIC(80)", "VARGRAPHIC(80)", "DBCLOB(80)", "BLOB(80)", "FAIL")
108108
co1 <- c(rep("NOT NULL", length(ct1)))
109109

110-
expect_silent(generate_sql_create_table("testtable", cn1[1:3], ct1[1:3]))
110+
expect_silent(sql_create_table("testtable", cn1[1:3], ct1[1:3]))
111111
expect_error(
112-
generate_sql_create_table("testtable", cn1[1:3], ct1[1:2]),
112+
sql_create_table("testtable", cn1[1:3], ct1[1:2]),
113113
"is_equal_length"
114114
)
115115

116116
ct1[[1]] <- NA
117117

118118
expect_message(
119-
generate_sql_create_table("testtable", cn1[1:3], ct1[1:3]),
119+
sql_create_table("testtable", cn1[1:3], ct1[1:3]),
120120
"Skipping 1"
121121
)
122122

123123
cn1[[1]] <- NA
124124
expect_error(
125-
generate_sql_create_table("testtable", cn1[1:3], ct1[1:3]),
125+
sql_create_table("testtable", cn1[1:3], ct1[1:3]),
126126
"must be unique"
127127
)
128128

129129
cn1[[1]] <- "B"
130130
expect_error(
131-
generate_sql_create_table("testtable", cn1[1:3], ct1[1:3]),
131+
sql_create_table("testtable", cn1[1:3], ct1[1:3]),
132132
"must be unique"
133133
)
134134
})

0 commit comments

Comments
 (0)