Skip to content

Commit 16df325

Browse files
authored
[core][fix] arangosearch predicates with array access (#2179)
1 parent 7cda232 commit 16df325

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

fixcore/fixcore/db/arango_query.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,8 @@ def view_term(term: Term) -> Tuple[Optional[str], Term]:
270270
# we filter the list down as much as possible, but leave the context term untouched
271271
is_array_context = bool(array_marker.search(term.name))
272272
context_in_array = context_in_array or is_array_context
273-
# arangosearch view does not handle nested array searches correctly
274-
# see: https://github.com/arangodb/arangodb/issues/21281
275-
# once this is resolved we can enable the next 3 lines
276-
#
277-
# sp, ct = view_term(term.predicate_term())
278-
# return sp, term if is_array_context else ct
279-
return (None, term) if is_array_context else view_term(term.predicate_term())
273+
sp, ct = view_term(term.predicate_term())
274+
return sp, term if is_array_context else ct
280275
elif isinstance(term, IdTerm):
281276
if len(term.ids) == 1:
282277
sp = f"{crs}._key == @{ctx.add_bind_var(term.ids[0])}"
@@ -301,6 +296,12 @@ def view_term(term: Term) -> Tuple[Optional[str], Term]:
301296
return None, term
302297
return combine_optional(lsp, rsp, lambda ll, rr: f"({ll} {term.op} {rr})"), lt.combine(term.op, rt)
303298
elif isinstance(term, Predicate):
299+
# arangosearch view does not handle nested array searches correctly
300+
# see: https://github.com/arangodb/arangodb/issues/21281
301+
# once this is resolved we can delete the next 2 lines
302+
if term.op in ["!=", "not in"] and bool(array_marker.search(term.name)):
303+
return "true", term # true will not filter anything leaving the term for the filter
304+
304305
return predicate_term(term)
305306
else:
306307
return None, term

fixcore/tests/fixcore/db/arango_query_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ def assert_view(query: str, expected: str, **kwargs: Any) -> Tuple[str, Json]:
437437
# asking for a specific element in an array can leverage the view
438438
assert_view("g[*]==1", "SEARCH v0.g == @b0 RETURN v0")
439439
assert_view("g[*] in [1,2,3]", "SEARCH v0.g in @b0 RETURN v0) FOR result in view0")
440-
assert_view("g[*] not in [1,2,3]", "SEARCH v0.g not in @b0 RETURN v0) FOR result in view0")
441440
# use like instead of regex
442441
if TranslateRegexpToLike:
443442
assert_view('name=~"^123"', "SEARCH v0.name LIKE @b0", b0="123%")

0 commit comments

Comments
 (0)