Hi, it appears that query_graph has at least two separate problems in its Cypher handling. Yes, the below is coming from AI but figured it would be best to provide the examples it tried and then what it should be then me. .
- function casting with
toInteger(...) returns empty strings instead of integers
- literal expressions in
RETURN fail parsing, even inside a valid MATCH ... RETURN ... query
This blocks normal numeric filtering and computed projections, for example class size calculations from start_line / end_line.
Environment
- MCP:
codebase-memory-mcp
- Tool:
query_graph
Minimal repros
1. Control case: raw property read works
MATCH (c:Class {name: '_PDFIngestJob'})
RETURN c.start_line AS start_line
LIMIT 1
Actual result
{"columns":["start_line"],"rows":[["905"]],"total":1}
2. Another raw property read also works
MATCH (c:Class {name: '_PDFIngestJob'})
RETURN c.end_line
LIMIT 1
** Actual result**
{"columns":["c.end_line"],"rows":[["7007"]],"total":1}
So raw reads are working, and the returned values appear to be strings.
3. Cast of a string literal is broken
MATCH (c:Class {name: '_PDFIngestJob'})
RETURN toInteger('905') AS n
LIMIT 1
Actual result
{"columns":["toInteger"],"rows":[[""]],"total":1}
Expected result
{"columns":["n"],"rows":[[905]],"total":1}
4. Cast of a property is broken
MATCH (c:Class {name: '_PDFIngestJob'})
RETURN c.start_line AS start_line, toInteger(c.start_line) AS start_line_int
LIMIT 1
Actual result
{"columns":["start_line","toInteger"],"rows":[["905",""]],"total":1}
Observed issues in this result
- toInteger(...) returns "" instead of an integer
- the alias start_line_int is ignored, and the returned column name is "toInteger"
5. Literal expression in RETURN fails parsing
MATCH (c:Class {name: '_PDFIngestJob'})
RETURN 1
LIMIT 1
Actual error
expected token type 85, got 87 at pos 47
6. Arithmetic expression in RETURN fails parsing
MATCH (c:Class {name: '_PDFIngestJob'})
RETURN 1 + 1 AS two
LIMIT 1
Actual error
expected token type 85, got 87 at pos 47
7. Bare RETURN query also parser-fails
Actual error
expected token type 0, got 2 at pos 0
Why this matters
This prevents straightforward numeric queries such as:
MATCH (c:Class)
WHERE c.start_line <> '' AND c.end_line <> ''
RETURN
c.name,
toInteger(c.end_line) - toInteger(c.start_line) + 1 AS line_count
or queries such as:
MATCH (c:Class)
WHERE c.start_line IS NOT NULL
AND c.end_line IS NOT NULL
AND (toInteger(c.end_line) - toInteger(c.start_line) + 1) > 1200
RETURN
c.name AS name,
c.file_path AS file_path,
c.start_line AS start_line,
c.end_line AS end_line,
(toInteger(c.end_line) - toInteger(c.start_line) + 1) AS line_count
ORDER BY line_count DESC
LIMIT 50
Without working casts and arithmetic, class-size and similar graph analyses have to be done outside the graph query.
Observed behavior summary
- raw property projection works
- numeric-looking properties come back as strings
- toInteger(...) executes but returns empty strings
- aliases on function expressions are not preserved in the returned columns
- literal expressions in RETURN fail parsing
Expected behavior
- toInteger('905') should return 905
- toInteger(c.start_line) should return an integer value
- aliases like AS n and AS start_line_int should be preserved in columns
- RETURN 1 and RETURN 1 + 1 AS two should parse and execute normally inside valid Cypher
Impact
This makes it impossible to do simple numeric filtering or derived calculations inside query_graph, including line-count filters for large classes/modules and similar structural analysis workflows.
Hi, it appears that
query_graphhas at least two separate problems in its Cypher handling. Yes, the below is coming from AI but figured it would be best to provide the examples it tried and then what it should be then me. .toInteger(...)returns empty strings instead of integersRETURNfail parsing, even inside a validMATCH ... RETURN ...queryThis blocks normal numeric filtering and computed projections, for example class size calculations from
start_line/end_line.Environment
codebase-memory-mcpquery_graphMinimal repros
1. Control case: raw property read works
Actual result
{"columns":["start_line"],"rows":[["905"]],"total":1}2. Another raw property read also works
** Actual result**
So raw reads are working, and the returned values appear to be strings.
3. Cast of a string literal is broken
Actual result
Expected result
4. Cast of a property is broken
Actual result
Observed issues in this result
5. Literal expression in RETURN fails parsing
Actual error
6. Arithmetic expression in RETURN fails parsing
Actual error
7. Bare RETURN query also parser-fails
Actual error
Why this matters
This prevents straightforward numeric queries such as:
or queries such as:
Without working casts and arithmetic, class-size and similar graph analyses have to be done outside the graph query.
Observed behavior summary
Expected behavior
Impact
This makes it impossible to do simple numeric filtering or derived calculations inside query_graph, including line-count filters for large classes/modules and similar structural analysis workflows.