Skip to content

Commit

Permalink
refactored LIKE predicate and test. closes geopython#20
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmith013 committed Jul 9, 2021
1 parent 196b2ff commit 598ae6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 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 @@ -159,12 +159,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
6 changes: 2 additions & 4 deletions tests/parsers/cql_json/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,12 @@ def test_attribute_between_negative_positive():

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

0 comments on commit 598ae6a

Please sign in to comment.