Skip to content

Update CASEI implementation to support LIKE#142

Merged
tomkralidis merged 3 commits into
geopython:mainfrom
mikemahoney218-usgs:casei_like
May 30, 2026
Merged

Update CASEI implementation to support LIKE#142
tomkralidis merged 3 commits into
geopython:mainfrom
mikemahoney218-usgs:casei_like

Conversation

@mikemahoney218-usgs
Copy link
Copy Markdown
Contributor

This PR updates the Lark grammar for CQL2 Text and adds tests for both CQL2 text and JSON to make CASEI work appropriately on the right-hand side of LIKE statements.

@mikemahoney218-usgs
Copy link
Copy Markdown
Contributor Author

@tomkralidis This PR should fix the issues caught by pygeoapi. There's still one bug in the CI which I'll also mention on geopython/pygeoapi#2018 -- the CROSSES in the test case needs to be updated to S_CROSSES instead.

evaluate(db_session, "CASEI(strAttribute) NOT LIKE CASEI('aaa')", ("B", ), None, parse_cql_text)

def test_casei_in(db_session):
evaluate(db_session, "CASEI(strAttribute) IN (CASEI('aaa'), CASEI('bbb'))", ("A", "B", ), None, parse_cql_text)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no changes here that impact how IN requests work, but I figured it was worth confirming given we ran into bugs with LIKE and NOT LIKE

def test_casei_function():
result = parse("CASEI(provider) = 'coolsat'")
def test_casei_equals():
result = parse("CASEI(provider) = CASEI('coolsat')")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard mentions that implementations can choose to fold either to upper or lower case, so users are required to apply CASEI to both the attribute and the literal to guarantee correct results. It would be allowed for pygeofilter to start using upper instead of lower in the future, for instance.

@mikemahoney218-usgs
Copy link
Copy Markdown
Contributor Author

Actually, sorry, I think I pinged too soon -- I want to fix pygeoapi CI before I treat this as solved. Converting to draft and I'll re-ping when I think this is ready.

@mikemahoney218-usgs mikemahoney218-usgs marked this pull request as draft May 27, 2026 20:27
@mikemahoney218-usgs mikemahoney218-usgs marked this pull request as ready for review May 27, 2026 21:22
@mikemahoney218-usgs
Copy link
Copy Markdown
Contributor Author

Turns out all the necessary changes were in pygeoapi -- this change should be ready for review.

@tomkralidis tomkralidis merged commit db7b553 into geopython:main May 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants