Skip to content

Commit

Permalink
Add str_c() translation for Oracle (#921)
Browse files Browse the repository at this point in the history
* Add `str_c()` translation for Oracle

* NEWS
  • Loading branch information
mgirlich authored Jun 23, 2022
1 parent d321898 commit f6258f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Querying Oracle databases works again. Unfortunately, the fix requires every
column to be explicitly selected again (@mgirlich, #908).

* `str_c()` is now translated to `||` in Oracle (@mgirlich, #921).

* `semi_join()` and `anti_join()` work again for Spark (@mgirlich, #915).

* `sd()`, `var()`, `cor()` and `cov()` now give clear error messages on
Expand Down
1 change: 1 addition & 0 deletions R/backend-oracle.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ sql_translation.Oracle <- function(con) {
# https://docs.oracle.com/cd/B19306_01/server.102/b14200/operators003.htm#i997789
paste = sql_paste_infix(" ", "||", function(x) sql_expr(cast(!!x %as% text))),
paste0 = sql_paste_infix("", "||", function(x) sql_expr(cast(!!x %as% text))),
str_c = sql_paste_infix("", "||", function(x) sql_expr(cast(!!x %as% text))),

# lubridate --------------------------------------------------------------
today = function() sql_expr(TRUNC(CURRENT_TIMESTAMP)),
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-backend-oracle.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test_that("paste and paste0 translate correctly", {

expect_equal(translate_sql(paste(x, y)), sql("`x` || ' ' || `y`"))
expect_equal(translate_sql(paste0(x, y)), sql("`x` || `y`"))
expect_equal(translate_sql(str_c(x, y)), sql("`x` || `y`"))
})

test_that("queries translate correctly", {
Expand Down

0 comments on commit f6258f1

Please sign in to comment.