Fix malformed CQL from spatial filters#369
Open
boshek wants to merge 4 commits into
Open
Conversation
ateucher
reviewed
Jun 23, 2026
Comment on lines
+199
to
+206
| single <- cql(filter(promise, INTERSECTS(bbox))) | ||
| expect_false(grepl("drop_null", single)) | ||
| expect_false(grepl("^\\(\\(", single)) | ||
|
|
||
| # A chained second clause AND-joins cleanly, still without the artifact. | ||
| multi <- cql(filter(filter(promise, INTERSECTS(bbox)), BGC_LABEL != "ZZZ")) | ||
| expect_false(grepl("drop_null", multi)) | ||
| expect_match(multi, "AND \\(\"BGC_LABEL\" != 'ZZZ'\\)") |
Collaborator
There was a problem hiding this comment.
I feel like this is a good place for snapshot tests - less messy grepping, and I think it would be nice to visually inspect the CQL
Comment on lines
+332
to
+334
| combined_cql <- c(unclass(.data$query_list$CQL_FILTER), unclass(current_cql)) | ||
| combined_cql <- combined_cql[nzchar(combined_cql)] | ||
| .data$query_list$CQL_FILTER <- dbplyr::sql(combined_cql) |
Collaborator
There was a problem hiding this comment.
I think this can be simplified to just combine them with dbplyr::sql():
Suggested change
| combined_cql <- c(unclass(.data$query_list$CQL_FILTER), unclass(current_cql)) | |
| combined_cql <- combined_cql[nzchar(combined_cql)] | |
| .data$query_list$CQL_FILTER <- dbplyr::sql(combined_cql) | |
| .data$query_list$CQL_FILTER <- dbplyr::sql( | |
| .data$query_list$CQL_FILTER, | |
| current_cql | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a bug where
filter()calls using CQL geometry predicates (such asINTERSECTS()) produced malformed CQL that the server rejected with a 400 error.The reason the CQL was malformed was because CQL leaked a spurious
TRUE AS "drop_null"clause and extra parentheses following the removal ofc.sql()method in dbplyr 2.6.0 (tidyverse/dbplyr#1691).Closes (#368)