Skip to content

Commit 8052b05

Browse files
author
rsmith013
committed
refactoring LIKE predicate from cql-json to match OGC docs. closes #20
1 parent 7d31dad commit 8052b05

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

pygeofilter/parsers/cql_json/parser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ def walk_cql_json(node: dict, is_temporal: bool = False) -> ast.Node:
164164

165165
elif name == 'like':
166166
return ast.Like(
167-
walk_cql_json(value['like'][0]),
168-
value['like'][1],
169-
nocase=value.get('nocase', True),
170-
wildcard=value.get('wildcard', '%'),
171-
singlechar=value.get('singleChar', '.'),
172-
escapechar=value.get('escapeChar', '\\'),
167+
walk_cql_json(value[0]),
168+
value[1],
169+
nocase=node.get('nocase', True),
170+
wildcard=node.get('wildcard', '%'),
171+
singlechar=node.get('singleChar', '.'),
172+
escapechar=node.get('escapeChar', '\\'),
173173
not_=False,
174174
)
175175

tests/parsers/cql_json/test_parser.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,11 @@ def test_attribute_between_negative_positive():
140140

141141
def test_string_like():
142142
result = parse({
143-
"like": {
144-
"like": [
145-
{"property": "attr"},
146-
"some%",
147-
],
148-
"nocase": False,
149-
}
143+
"like": [
144+
{"property": "attr"},
145+
"some%",
146+
],
147+
"nocase": False,
150148
})
151149
assert result == ast.Like(
152150
ast.Attribute('attr'),
@@ -161,13 +159,11 @@ def test_string_like():
161159

162160
def test_string_ilike():
163161
result = parse({
164-
"like": {
165-
"like": [
166-
{"property": "attr"},
167-
"some%",
168-
],
169-
"nocase": True,
170-
}
162+
"like": [
163+
{"property": "attr"},
164+
"some%",
165+
],
166+
"nocase": True,
171167
})
172168
assert result == ast.Like(
173169
ast.Attribute('attr'),

0 commit comments

Comments
 (0)