Skip to content

Commit

Permalink
refactoring LIKE predicate from cql-json to match OGC docs. closes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmith013 committed Jul 9, 2021
1 parent 7d31dad commit 8052b05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
12 changes: 6 additions & 6 deletions pygeofilter/parsers/cql_json/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ def walk_cql_json(node: dict, is_temporal: bool = False) -> ast.Node:

elif name == 'like':
return ast.Like(
walk_cql_json(value['like'][0]),
value['like'][1],
nocase=value.get('nocase', True),
wildcard=value.get('wildcard', '%'),
singlechar=value.get('singleChar', '.'),
escapechar=value.get('escapeChar', '\\'),
walk_cql_json(value[0]),
value[1],
nocase=node.get('nocase', True),
wildcard=node.get('wildcard', '%'),
singlechar=node.get('singleChar', '.'),
escapechar=node.get('escapeChar', '\\'),
not_=False,
)

Expand Down
24 changes: 10 additions & 14 deletions tests/parsers/cql_json/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,11 @@ def test_attribute_between_negative_positive():

def test_string_like():
result = parse({
"like": {
"like": [
{"property": "attr"},
"some%",
],
"nocase": False,
}
"like": [
{"property": "attr"},
"some%",
],
"nocase": False,
})
assert result == ast.Like(
ast.Attribute('attr'),
Expand All @@ -161,13 +159,11 @@ def test_string_like():

def test_string_ilike():
result = parse({
"like": {
"like": [
{"property": "attr"},
"some%",
],
"nocase": True,
}
"like": [
{"property": "attr"},
"some%",
],
"nocase": True,
})
assert result == ast.Like(
ast.Attribute('attr'),
Expand Down

0 comments on commit 8052b05

Please sign in to comment.