Repository navigation
Description
ArcadeDB version
- Docker image:
arcadedata/arcadedb:latest - Observed version:
26.7.2-SNAPSHOT - Build:
614f684589176b391059c9a985fbe99d34891628/1783267915250/main - Retested on: 2026-07-06
- Endpoint: HTTP
/api/v1/command/test - Language:
opencypher
Description
A correlated EXISTS { ... } predicate combined with AND NOT EXISTS { ... } drops a row that should match.
In the reproducer below, user 1 is active, has one outgoing FRIEND relationship, and that friend has active = false. Therefore user 1 satisfies both predicates:
EXISTS { MATCH (u)-[:FRIEND]->(:User) }NOT EXISTS { MATCH (u)-[:FRIEND]->(f:User) WHERE f.active IS NULL OR f.active = true }
However, ArcadeDB does not update the matching user. The query completes without error, but no row is written.
The semantically equivalent control query using OPTIONAL MATCH, collect(), and all() works correctly on the same graph.
Reproduce
Please run from a clean database.
If using HTTP /api/v1/command/test, submit each statement separately, but keep the CREATE statement below as one command so the variables remain in scope.
MATCH (n) DETACH DELETE n;CREATE
(u1:User {id: 1, active: true}),
(u2:User {id: 2, active: false}),
(u3:User {id: 3, active: true}),
(u1)-[:FRIEND]->(u2),
(u3)-[:FRIEND]->(u1);Failing query:
MATCH (u:User {active: true})
WHERE EXISTS {
MATCH (u)-[:FRIEND]->(:User)
}
AND NOT EXISTS {
MATCH (u)-[:FRIEND]->(f:User)
WHERE f.active IS NULL OR f.active = true
}
SET u.flagged = true;Readback:
MATCH (u:User)
WHERE u.flagged = true
RETURN u.id AS uid
ORDER BY uid;Expected behavior
uid = 1
Only user 1 should be flagged:
u1is active.u1has one outgoingFRIEND.u1's only friend isu2, whereu2.active = false.- Therefore the positive
EXISTSpredicate is true. - The negative
NOT EXISTSpredicate is also true, because there is no friend ofu1withactive IS NULLoractive = true.
User 3 should not be flagged, because u3 has friend u1, and u1.active = true.
Actual behavior
Observed on arcadedata/arcadedb:latest, version 26.7.2-SNAPSHOT, build 614f684589176b391059c9a985fbe99d34891628/1783267915250/main:
(empty result)
No user is flagged.
Control: equivalent query works
Please run from a clean database.
MATCH (n) DETACH DELETE n;CREATE
(u1:User {id: 1, active: true}),
(u2:User {id: 2, active: false}),
(u3:User {id: 3, active: true}),
(u1)-[:FRIEND]->(u2),
(u3)-[:FRIEND]->(u1);Equivalent query without correlated EXISTS / NOT EXISTS composition:
MATCH (u:User {active: true})
OPTIONAL MATCH (u)-[:FRIEND]->(f:User)
WITH u, collect(f) AS friends
WHERE size(friends) > 0
AND all(x IN friends WHERE x.active = false)
SET u.flagged = true;Readback:
MATCH (u:User)
WHERE u.flagged = true
RETURN u.id AS uid
ORDER BY uid;Observed on the same ArcadeDB build:
uid = 1
Why this looks like a bug
- The graph contains a matching user.
- The failing query is accepted and completes without error.
- No user is updated, even though user
1satisfies both predicates. - The equivalent
OPTIONAL MATCH + collect() + all()formulation updates user1correctly. - The issue is not caused by missing data, write failure, or readback failure.
- The failure appears specific to composing a correlated positive
EXISTS { ... }predicate with a correlatedAND NOT EXISTS { ... }predicate.
Activity
shulei5831sl commentedon Jul 5, 2026
I updated the issue description with a smaller deterministic reproducer and retested it on the current
arcadedata/arcadedb:latestimage.Retested environment:
26.7.2-SNAPSHOT614f684589176b391059c9a985fbe99d34891628/1783267915250/main/api/v1/command/testopencypherThe new reproducer removes the random-seed graph and keeps only the minimal case: one active user with one inactive friend.
The failure is still:
uid = 1The equivalent
OPTIONAL MATCH + collect() + all()control query still returnsuid = 1on the same build.So the issue appears to be deterministic and specific to the composition of correlated
EXISTS { ... }with correlatedAND NOT EXISTS { ... }, rather than random seed initialization.fix(#4995): parenthesize existing WHERE body when correlating EXISTS …
lvca commentedon Jul 5, 2026
Fixed in main (commit 535e261), will ship in the next release.
What was happening: when a correlated
EXISTS { ... }/NOT EXISTS { ... }subquery had a WHERE with a top-levelOR(likeWHERE f.active IS NULL OR f.active = true), the engine linked the outer correlation to only the first side of theOR, becauseANDbinds tighter thanOR. As a result the subquery matched unrelated users and dropped rows that should have matched.Your reproducer now correctly flags
uid = 1. Thanks for the clear, deterministic report.fix(engine) #5656: a Cypher subquery body is part of the query, not a…
fix(engine) #5656: a Cypher subquery body is part of the query, not a…
fix(#4995): parenthesize existing WHERE body when correlating EXISTS …
fix(engine) #5656: a Cypher subquery body is part of the query, not a…