Skip to content

Commit

Permalink
Avoid .dots argument
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored and aviator-bot committed Dec 24, 2023
1 parent 98da043 commit f765cba
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions R/spec-result-roundtrip.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec_result_roundtrip <- list(
sql_names <- paste0("CAST(", int_values, " AS ", dbDataType(con, logical()), ")")

#' with NA for SQL `NULL` values
test_select_with_null(.ctx = ctx, con, .dots = setNames(values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(values, sql_names))
},

data_character = function(ctx, con) {
Expand All @@ -36,8 +36,8 @@ spec_result_roundtrip <- list(
sql_names <- as.character(dbQuoteString(con, values))

#' with NA for SQL `NULL` values
test_select_with_null(.ctx = ctx, con, .dots = setNames(values, sql_names))
test_select_with_null(.ctx = ctx, con, .dots = setNames(test_funs, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(test_funs, sql_names))
},

data_raw = function(ctx, con) {
Expand All @@ -54,7 +54,7 @@ spec_result_roundtrip <- list(
sql_names <- ctx$tweaks$blob_cast(DBI::dbQuoteLiteral(con, list(raw(1))))

#' with [NULL] entries for SQL NULL values
test_select_with_null(.ctx = ctx, con, .dots = setNames(values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(values, sql_names))
},

data_date = function(ctx, con) {
Expand All @@ -70,7 +70,7 @@ spec_result_roundtrip <- list(
sql_names <- ctx$tweaks$date_cast(char_values)

#' with NA for SQL `NULL` values
test_select_with_null(.ctx = ctx, con, .dots = setNames(values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(values, sql_names))
},

data_date_current = function(ctx, con) {
Expand All @@ -94,7 +94,7 @@ spec_result_roundtrip <- list(
sql_names <- ctx$tweaks$time_cast(char_values)

#' with NA for SQL `NULL` values
test_select_with_null(.ctx = ctx, con, .dots = setNames(time_values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(time_values, sql_names))
},

data_time_current = function(ctx, con) {
Expand All @@ -117,7 +117,7 @@ spec_result_roundtrip <- list(
sql_names <- ctx$tweaks$timestamp_cast(char_values)

#' with NA for SQL `NULL` values
test_select_with_null(.ctx = ctx, con, .dots = setNames(time_values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(time_values, sql_names))
},

data_timestamp_current = function(ctx, con) {
Expand Down Expand Up @@ -148,7 +148,7 @@ spec_result_roundtrip <- list(
values <- lapply(char_values, as_numeric_date)
sql_names <- ctx$tweaks$date_cast(char_values)

test_select_with_null(.ctx = ctx, con, .dots = setNames(values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(values, sql_names))
},

data_date_current_typed = function(ctx, con) {
Expand All @@ -173,7 +173,7 @@ spec_result_roundtrip <- list(
timestamp_values <- rep(list(is_timestamp), 2L)
sql_names <- ctx$tweaks$timestamp_cast(char_values)

test_select_with_null(.ctx = ctx, con, .dots = setNames(timestamp_values, sql_names))
test_select_with_null(.ctx = ctx, con, !!!setNames(timestamp_values, sql_names))
},

data_timestamp_current_typed = function(ctx, con) {
Expand Down Expand Up @@ -207,7 +207,7 @@ spec_result_roundtrip <- list(
char_values <- c("10000000000", "-10000000000")
test_values <- as_numeric_identical_to(as.numeric(char_values))

test_select_with_null(.ctx = ctx, con, .dots = setNames(test_values, char_values))
test_select_with_null(.ctx = ctx, con, !!!setNames(test_values, char_values))
},

#' - Loss of precision when converting to numeric gives a warning
Expand All @@ -224,17 +224,17 @@ spec_result_roundtrip <- list(

suppressWarnings(
expect_warning(
test_select(.ctx = ctx, con, .dots = setNames(test_values, char_values), .add_null = "none")
test_select(.ctx = ctx, con, !!!setNames(test_values, char_values), .add_null = "none")
)
)
suppressWarnings(
expect_warning(
test_select(.ctx = ctx, con, .dots = setNames(test_values, char_values), .add_null = "above")
test_select(.ctx = ctx, con, !!!setNames(test_values, char_values), .add_null = "above")
)
)
suppressWarnings(
expect_warning(
test_select(.ctx = ctx, con, .dots = setNames(test_values, char_values), .add_null = "below")
test_select(.ctx = ctx, con, !!!setNames(test_values, char_values), .add_null = "below")
)
)
},
Expand All @@ -251,7 +251,7 @@ spec_result_roundtrip <- list(
char_values <- c("1234567890123456789", "-1234567890123456789")
test_values <- as_character_equals_to(char_values)

test_select_with_null(.ctx = ctx, con, .dots = setNames(test_values, char_values))
test_select_with_null(.ctx = ctx, con, !!!setNames(test_values, char_values))
},
#
NULL
Expand All @@ -264,9 +264,13 @@ test_select_with_null <- function(...) {
test_select(..., .add_null = "below")
}

test_select <- function(con, ..., .dots = NULL, .add_null = "none",
.ctx, .envir = parent.frame()) {
values <- c(list(...), .dots)
test_select <- function(
con,
...,
.add_null = "none",
.ctx,
.envir = parent.frame()) {
values <- list2(...)

value_is_formula <- vapply(values, is.call, logical(1L))
names(values)[value_is_formula] <- lapply(values[value_is_formula], "[[", 2L)
Expand Down

0 comments on commit f765cba

Please sign in to comment.