Skip to content

Commit

Permalink
Test for unknown infix and vector value - fixes #1299
Browse files Browse the repository at this point in the history
  • Loading branch information
mgirlich committed Jun 30, 2023
1 parent ed6b09c commit 0d1659e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
5 changes: 0 additions & 5 deletions tests/testthat/_snaps/build-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
Condition
Error in `glue_check_collapse()`:
! Collapsing is only allowed for "col" and "val", not for "name".
Code
glue_sql2("{.sql x*}", .con = con)
Condition
Error in `glue_check_collapse()`:
! Collapsing is only allowed for "col" and "val", not for "sql".
Code
glue_sql2("{.from x*}", .con = con)
Condition
Expand Down
7 changes: 0 additions & 7 deletions tests/testthat/test-build-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ test_that("glue_sql() interpolates .name correctly", {
expect_equal(glue_sql2("{.name ident_q('ta ble')}", .con = con), sql("ta ble"))
})

test_that("glue_sql() interpolates .sql correctly", {
con <- simulate_dbi()
expect_equal(glue_sql2("{.sql 'ta ble'}", .con = con), sql("ta ble"))
expect_equal(glue_sql2("{.sql sql('ta ble')}", .con = con), sql("ta ble"))
})

test_that("glue_sql() interpolates .col correctly", {
con <- simulate_dbi()
expect_equal(glue_sql2("{.col 'x'}", .con = con), sql("`x`"))
Expand Down Expand Up @@ -76,7 +70,6 @@ test_that("glue_sql() can collapse", {
expect_snapshot(error = TRUE, {
glue_sql2("{.tbl x*}", .con = con)
glue_sql2("{.name x*}", .con = con)
glue_sql2("{.sql x*}", .con = con)
glue_sql2("{.from x*}", .con = con)
})
})
3 changes: 3 additions & 0 deletions tests/testthat/test-translate-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ test_that("magrittr pipe is translated", {
test_that("user infix functions are translated", {
local_con(simulate_dbi())
expect_equal(test_translate_sql(x %like% y), sql("`x` like `y`"))

# keep case and also works with vectors of length > 1 #1299
expect_equal(test_translate_sql(x %LIKE% 1:2), sql("`x` LIKE (1, 2)"))
})

test_that("sql() evaluates input locally", {
Expand Down

0 comments on commit 0d1659e

Please sign in to comment.