Skip to content

Cypher: label tests in WHERE clause (WHERE n:Label) not supported #241

@maksodf

Description

@maksodf

Environment

  • cbm version: 0.6.0
  • Platform: macOS (Darwin arm64)

Bug

Label tests in WHERE clauses (standard openCypher syntax WHERE n:Label) are not supported. The parser rejects them outright.

Minimal reproducer

MATCH (n)
WHERE n:Class OR n:Method
  AND n.file_path CONTAINS 'JarvisApp.swift'
RETURN count(n) AS c

Expected: count of nodes that are either Class or Method labels in JarvisApp.swift.
Actual: parse error — expected token type 67, got 73 at pos 18.

Both individual WHERE n:Class and WHERE n:Method also fail, so this isn't specific to OR.

Root cause

src/cypher/cypher.hcbm_condition_t (line 184) has slots for variable, property, op, value, but no slot for label tests. The AST can't represent n:Label as a condition.

This is an architectural limitation — fixing it requires:

  1. Extending cbm_condition_t with a const char *label_test field (or a new condition variant)
  2. Teaching parse_condition_expr (line 826) to recognize variable:Label in WHERE clauses
  3. Teaching eval_condition (line 1914) to check labels against the node

Workaround (current)

Use pattern-level label filtering: MATCH (n:Class) WHERE n.file_path CONTAINS 'JarvisApp.swift'. But this doesn't support OR-of-labels, which is the main reason to use WHERE-level label tests.

Medium-complexity fix — AST change + parser + executor. Reporting for visibility and roadmap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcypherCypher query language parser/executor bugs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions