Skip to content

MERGE succeeds even when node variable is NULL #3465

@swf2000

Description

@swf2000

Memgraph version
3.6.1

Environment
Operating System: window 11
Installation Method: Docker
API: Docker

Describe the bug
When executing the following query on an empty graph:
OPTIONAL MATCH (n0)
WITH n0 AS alias0
WHERE false
MERGE (alias0) <-[:rt0]- (alias0)
RETURN *;
Memgraph incorrectly succeeds, returning:
No data returned.
Because the graph is empty, OPTIONAL MATCH (n0) already binds alias0 to NULL.
After WHERE false, all rows are removed and alias0 is still NULL.
According to Cypher semantics, MERGE must not accept NULL as a node variable.
It should raise a type error such as:
Expected a vertex for 'alias0', but got null.
Memgraph only raises this error when the WHERE false line is removed.

Expected behavior
Even in an empty graph, MERGE should validate its inputs and fail when the node variable is NULL.
The command should error with:
Expected a vertex for 'alias0', but got null.

Actual behavior
Memgraph silently succeeds and returns:
No data returned.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions