Skip to content

Commit

Permalink
Prepare for upcoming R-devel change (#1369)
Browse files Browse the repository at this point in the history
Where `is.atomic(NULL)` will return `FALSE`
  • Loading branch information
hadley committed Sep 26, 2023
1 parent 18c1291 commit e895507
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/sql-expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ sql_call2 <- function(.fn, ..., con = sql_current_con()) {


replace_expr <- function(x, con) {
if (is.atomic(x) || blob::is_blob(x)) {
if (is.null(x)) {
"NULL"
} else if (is.atomic(x) || blob::is_blob(x)) {
as.character(escape(unname(x), con = con))
} else if (is.name(x)) {
as.character(x)
Expand Down
2 changes: 1 addition & 1 deletion R/translate-sql-window.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ translate_window_where_all <- function(x, window_funs = common_window_funs()) {
}

window_where <- function(expr, comp) {
stopifnot(is.call(expr) || is.name(expr) || is.atomic(expr))
stopifnot(is.call(expr) || is.name(expr) || is.atomic(expr) || is.null(expr))
check_list(comp)

list(
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-sql-expr.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
test_that("NULL becomes SQL NULL", {
con <- simulate_dbi()
expect_equal(sql_expr(NULL), sql("NULL"))
})

test_that("atomic vectors are escaped", {
con <- simulate_dbi()

Expand Down

0 comments on commit e895507

Please sign in to comment.