Skip to content

Commit f8dc977

Browse files
authored
[core][fix] Context query with array with or (#2084)
1 parent 1076b18 commit f8dc977

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fixcore/fixcore/db/arango_query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,9 @@ def term(
410410
pre_right, right, post_right = term(cursor, ab_term.right, context_path)
411411
pre = pre_left + " " + pre_right if pre_left and pre_right else pre_left if pre_left else pre_right
412412
post = (
413-
post_left + " AND " + post_right if post_left and post_right else post_left if post_left else post_right
413+
f"({post_left} {ab_term.op} {post_right})"
414+
if post_left and post_right
415+
else post_left if post_left else post_right
414416
)
415417
return pre, f"({left}) {ab_term.op} ({right})", post
416418
else:

fixcore/tests/fixcore/db/arango_query_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_context(foo_model: Model, graph_db: GraphDB) -> None:
121121
"FOR pre1 IN APPEND(TO_ARRAY(pre0.inner), {_internal: true}) "
122122
"FOR pre2 IN APPEND(TO_ARRAY(m0.reported.parents), {_internal: true}) "
123123
"FILTER ((@b0 IN m0.kinds) and ((pre0.name == @b1) and (pre1.name == @b2))) and (pre2.some_int == @b3) AND "
124-
"(pre0._internal!=true AND pre1._internal!=true AND pre2._internal!=true) "
124+
"((pre0._internal!=true AND pre1._internal!=true and pre2._internal!=true)) "
125125
"RETURN DISTINCT m0) "
126126
"FOR m1 in nested_distinct0 RETURN m1) "
127127
'FOR result in filter0 RETURN UNSET(result, ["flat"])'
@@ -140,7 +140,7 @@ def test_context(foo_model: Model, graph_db: GraphDB) -> None:
140140
"FOR pre2 IN APPEND(TO_ARRAY(m0.reported.parents), {_internal: true}) "
141141
"FILTER ((@b0 IN m0.kinds) and (NOT ((pre0.name == @b1) and (NOT (pre1.name == @b2))))) and "
142142
"(NOT (pre2.some_int == @b3)) AND "
143-
"(pre0._internal!=true AND pre1._internal!=true AND pre2._internal!=true) "
143+
"((pre0._internal!=true AND pre1._internal!=true and pre2._internal!=true)) "
144144
"RETURN DISTINCT m0) "
145145
"FOR m1 in nested_distinct0 RETURN m1) "
146146
'FOR result in filter0 RETURN UNSET(result, ["flat"])'

0 commit comments

Comments
 (0)