Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core][fix] Context query with array with or #2084

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fixcore/fixcore/db/arango_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ def term(
pre_right, right, post_right = term(cursor, ab_term.right, context_path)
pre = pre_left + " " + pre_right if pre_left and pre_right else pre_left if pre_left else pre_right
post = (
post_left + " AND " + post_right if post_left and post_right else post_left if post_left else post_right
f"({post_left} {ab_term.op} {post_right})"
if post_left and post_right
else post_left if post_left else post_right
)
return pre, f"({left}) {ab_term.op} ({right})", post
else:
Expand Down
4 changes: 2 additions & 2 deletions fixcore/tests/fixcore/db/arango_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_context(foo_model: Model, graph_db: GraphDB) -> None:
"FOR pre1 IN APPEND(TO_ARRAY(pre0.inner), {_internal: true}) "
"FOR pre2 IN APPEND(TO_ARRAY(m0.reported.parents), {_internal: true}) "
"FILTER ((@b0 IN m0.kinds) and ((pre0.name == @b1) and (pre1.name == @b2))) and (pre2.some_int == @b3) AND "
"(pre0._internal!=true AND pre1._internal!=true AND pre2._internal!=true) "
"((pre0._internal!=true AND pre1._internal!=true and pre2._internal!=true)) "
"RETURN DISTINCT m0) "
"FOR m1 in nested_distinct0 RETURN m1) "
'FOR result in filter0 RETURN UNSET(result, ["flat"])'
Expand All @@ -140,7 +140,7 @@ def test_context(foo_model: Model, graph_db: GraphDB) -> None:
"FOR pre2 IN APPEND(TO_ARRAY(m0.reported.parents), {_internal: true}) "
"FILTER ((@b0 IN m0.kinds) and (NOT ((pre0.name == @b1) and (NOT (pre1.name == @b2))))) and "
"(NOT (pre2.some_int == @b3)) AND "
"(pre0._internal!=true AND pre1._internal!=true AND pre2._internal!=true) "
"((pre0._internal!=true AND pre1._internal!=true and pre2._internal!=true)) "
"RETURN DISTINCT m0) "
"FOR m1 in nested_distinct0 RETURN m1) "
'FOR result in filter0 RETURN UNSET(result, ["flat"])'
Expand Down
Loading