Skip to content

Commit

Permalink
Remove the vars argument from translate_sql()
Browse files Browse the repository at this point in the history
`document()`

Add missing global variable "text"

Also remove `vars` from documentation
  • Loading branch information
mgirlich committed Mar 16, 2023
1 parent 339b1ff commit a93c845
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 23 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# dbplyr (development version)

* The `vars` argument of `translate_sql()` has been removed after it threw an
error for the last 7 years (@mgirlich).

* Added translation for `runif()` (@mgirlich, #1200).

* `sql_random()` is now deprecated. It was used to power `slice_sample()` which
Expand Down
2 changes: 1 addition & 1 deletion R/backend-redshift.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ supports_window_clause.Redshift <- function(con) {
#' @export
supports_window_clause.RedshiftConnection <- supports_window_clause.Redshift

utils::globalVariables(c("REGEXP_REPLACE", "LAG", "LEAD", "LISTAGG", "float"))
utils::globalVariables(c("REGEXP_REPLACE", "LAG", "LEAD", "LISTAGG", "float", "text"))
7 changes: 0 additions & 7 deletions R/translate-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#' a list of already quoted objects.
#' @param con An optional database connection to control the details of
#' the translation. The default, `NULL`, generates ANSI SQL.
#' @param vars Deprecated. Now call [partial_eval()] directly.
#' @param vars_group,vars_order,vars_frame Parameters used in the `OVER`
#' expression of windowed functions.
#' @param window Use `FALSE` to suppress generation of the `OVER`
Expand Down Expand Up @@ -67,16 +66,10 @@
#' translate_sql(cumsum(mpg), vars_order = "mpg")
translate_sql <- function(...,
con = NULL,
vars = character(),
vars_group = NULL,
vars_order = NULL,
vars_frame = NULL,
window = TRUE) {

if (!missing(vars)) {
cli_abort("{.arg vars} is deprecated. Please use {.fun partial_eval} directly.")
}

con <- con %||% sql_current_con() %||% simulate_dbi()

translate_sql_(
Expand Down
3 changes: 0 additions & 3 deletions man/translate_sql.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions tests/testthat/_snaps/translate-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,3 @@
Error:
! No known translation for `base::abbreviate()`

# vars is deprecated

Code
translate_sql(sin(x), vars = c("x", "y"))
Condition
Error in `translate_sql()`:
! `vars` is deprecated. Please use `partial_eval()` directly.

4 changes: 0 additions & 4 deletions tests/testthat/test-translate-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ test_that("magrittr pipe is translated", {
expect_identical(translate_sql(1 %>% is.na()), translate_sql(is.na(1)))
})

test_that("vars is deprecated", {
expect_snapshot(error = TRUE, translate_sql(sin(x), vars = c("x", "y")))
})

test_that("user infix functions are translated", {
expect_equal(translate_sql(x %like% y), sql("`x` like `y`"))
})
Expand Down

0 comments on commit a93c845

Please sign in to comment.