Skip to content

Commit fc02c97

Browse files
committed
sql_union()
1 parent 07b00ec commit fc02c97

7 files changed

+10
-7
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export(package_name)
2727
export(random_table_name)
2828
export(s4_methods)
2929
export(set_default_context)
30+
export(sql_union)
3031
export(test_all)
3132
export(test_compliance)
3233
export(test_connection)

R/spec-meta-get-row-count.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ spec_meta_get_row_count <- list(
2727
},
2828
#
2929
row_count_query_limited = function(ctx, con) {
30-
query <- union(.ctx = ctx, trivial_query(), "SELECT 2", "SELECT 3")
30+
query <- sql_union(.ctx = ctx, trivial_query(), "SELECT 2", "SELECT 3")
3131
res <- local_result(dbSendQuery(con, query))
3232
rc1 <- dbGetRowCount(res)
3333
expect_equal(rc1, 0L)
@@ -44,7 +44,7 @@ spec_meta_get_row_count <- list(
4444
#
4545
row_count_query_empty = function(ctx, con) {
4646
#' For queries with an empty result set,
47-
query <- union(
47+
query <- sql_union(
4848
.ctx = ctx, "SELECT * FROM (SELECT 1 as a) a WHERE (0 = 1)"
4949
)
5050
res <- local_result(dbSendQuery(con, query))

R/spec-result-fetch.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ spec_result_fetch <- list(
9696

9797
fetch_multi_row_multi_column = function(ctx, con) {
9898
#' or more columns by default returns the entire result.
99-
query <- union(
99+
query <- sql_union(
100100
.ctx = ctx, paste("SELECT", 1:5 + 0.5, "AS a,", 4:0 + 0.5, "AS b"), .order_by = "a"
101101
)
102102

R/spec-result-get-query.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ spec_result_get_query <- list(
120120

121121
get_query_multi_row_multi_column = function(ctx, con) {
122122
#' or more columns returns the entire result.
123-
query <- union(
123+
query <- sql_union(
124124
.ctx = ctx, paste("SELECT", 1:5 + 0.5, "AS a,", 4:0 + 0.5, "AS b"), .order_by = "a"
125125
)
126126

R/spec-result-roundtrip.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ test_select <- function(con, ..., .dots = NULL, .add_null = "none",
310310
query <- rev(query)
311311
}
312312
query <- paste0(query, ", ", 1:2, " as id")
313-
query <- union(.ctx = .ctx, query)
313+
query <- sql_union(.ctx = .ctx, query)
314314
}
315315

316316
rows <- check_df(dbGetQuery(con, query))

R/spec-result.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ spec_result <- c(
1515

1616
# Helpers -----------------------------------------------------------------
1717

18-
union <- function(..., .order_by = NULL, .ctx) {
18+
#' @export
19+
sql_union <- function(..., .order_by = NULL, .ctx) {
1920
query <- .ctx$tweaks$union(c(...))
2021

2122
if (!missing(.order_by)) {
@@ -34,7 +35,7 @@ trivial_query <- function(n = 1L, column = "a", .order_by = NULL, .ctx = NULL) {
3435
if (length(column) == n) {
3536
query <- paste0("SELECT ", paste0(value, " AS ", column, collapse = ", "))
3637
} else {
37-
query <- union(
38+
query <- sql_union(
3839
paste0("SELECT ", value, " AS ", column),
3940
.order_by = .order_by,
4041
.ctx = .ctx

R/use.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use_dbitest <- function(path) {
4444
"get_placeholder_funs",
4545
"has_utf8_or_ascii_encoding",
4646
#
47+
"sql_union",
4748
"trivial_query",
4849
"trivial_df",
4950
"trivial_values",

0 commit comments

Comments
 (0)