Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix queries with !match_case and only one value #317

Merged
merged 3 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
0.2.1.00x (dev version)
===================

## Minor changes

- Fix queries with !match_case and only one value (#317)

0.2.1
===================
Expand Down
2 changes: 1 addition & 1 deletion R/opq.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ paste_features <- function (key, value, key_pre = "", bind = "=",

} else {

if (length (value) > 1) {
if (length (value) > 1 || !match_case) {

# convert to OR'ed regex:
value <- paste (value, collapse = "|")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-osmdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_that ("add feature", {
)
qry4 <- add_osm_feature (qry, key = "highway", value = "!primary")
qry5 <- add_osm_feature (qry,
key = "highway", value = "!primary",
key = "highway", value = "primary",
match_case = FALSE
)
expect_identical (qry1$features, "[\"highway\"]")
Expand All @@ -51,7 +51,7 @@ test_that ("add feature", {
"[\"highway\"~\"^(primary|tertiary)$\"]"
)
expect_identical (qry4$features, "[\"highway\"!=\"primary\"]")
expect_identical (qry5$features, "[\"highway\"!=\"primary\",i]")
expect_identical (qry5$features, "[\"highway\"~\"^(primary)$\",i]")

bbox <- c (-0.118, 51.514, -0.115, 51.517)
qry <- opq (bbox = bbox)
Expand Down