From 0d1659ed3c45e230ece31e48d605526cfb210d12 Mon Sep 17 00:00:00 2001 From: Maximilian Girlich Date: Fri, 30 Jun 2023 11:33:13 +0000 Subject: [PATCH] Test for unknown infix and vector value - fixes #1299 --- tests/testthat/_snaps/build-sql.md | 5 ----- tests/testthat/test-build-sql.R | 7 ------- tests/testthat/test-translate-sql.R | 3 +++ 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/testthat/_snaps/build-sql.md b/tests/testthat/_snaps/build-sql.md index cc02ff71d..75c379e3a 100644 --- a/tests/testthat/_snaps/build-sql.md +++ b/tests/testthat/_snaps/build-sql.md @@ -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 diff --git a/tests/testthat/test-build-sql.R b/tests/testthat/test-build-sql.R index 9aef32575..0b2e9e4ea 100644 --- a/tests/testthat/test-build-sql.R +++ b/tests/testthat/test-build-sql.R @@ -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`")) @@ -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) }) }) diff --git a/tests/testthat/test-translate-sql.R b/tests/testthat/test-translate-sql.R index 6b5835db1..3a1d8873b 100644 --- a/tests/testthat/test-translate-sql.R +++ b/tests/testthat/test-translate-sql.R @@ -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", {