Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

booleanLiteral terminals parsed as attributes in cql2-text #95

Open
duckontheweb opened this issue May 24, 2024 · 0 comments
Open

booleanLiteral terminals parsed as attributes in cql2-text #95

duckontheweb opened this issue May 24, 2024 · 0 comments

Comments

@duckontheweb
Copy link
Contributor

System Info

Python Version: 3.10

OS: macOS Ventura 13.6.6

pygeofilter Version: 0.2.1 (main branch)

Problem Description

According to the OGC CQL2 documentation, a value of TRUE (case-insensitive) should be interpreted as a booleanLiteral value (see CQL2-Text example 14). So, for example, in the following query we should interpret attr as an attribute and TRUE as a booleanLiteral that we are comparing attr against:

attr = TRUE

However, the current CQL2 Text parser interprets the value of TRUE as an attribute. This leads to errors when we try to translate the AST to a backend like SQLAlchemy.

Steps to Reproduce:

from pygeofilter import ast
from pygeofilter.parsers.cql2_text import parse

result = parse("attr = TRUE")
assert result == ast.Equal(
    ast.Attribute("attr"),
    True,
)
# Assertion fails. The actual object is
# ast.Equal(
#     ast.Attribute("attr"),
#     ast.Attribute("TRUE")
# )

Possible Solution

I will put up a PR shortly with a possible solution that uses Lark's terminal priority to ensure that values of TRUE/true/FALSE/false are parsed as booleanLiteral values.

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

No branches or pull requests

1 participant