1. Readify CTO
  2. Neo4jClient
  3. Issues


Issue #45 resolved

Cyper should allow for flexible order of operators

Aran Mulholland
created an issue

The following query cannot be created with the current fluent query cypher implementation.

START me=node:node_auto_index(name='Bob')
MATCH me-[r?:STATUS]-secondlatestupdate
WITH me, secondlatestupdate
CREATE me-[:STATUS]->(latest_update{text:'Status',date:123})
WITH latest_update,secondlatestupdate
CREATE latest_update-[:NEXT]-secondlatestupdate
WHERE secondlatestupdate <> null
RETURN latest_update.text as new_status

The implementation of the ToQuery method in the CypherQueryBuilder has hard coded ordering. Delete always comes after the Match, Create and Where clauses. Queries need to be able to be flexible in their ordering to cope with a variety of situations.

Comments (13)

  1. Aran Mulholland reporter

    I think it should be more like string builder, but with parameters. The parameters help get you speed increases as neo4j will cache your queries and use them again. I think you should be able to add any operator in any order. If it forms an invalid query, so be it, it will be caught as a bad request. Or you could write a parser to determine if the query is valid (lex and yacc etc).

    It would be nice to start working on this. What do you think would be the simplest starting point?

  2. Tatham Oddie

    I think we're both on the same page. I'm not sure where to start, but I'm stuck in a pressurized cylindrical tube for the next few hours so I'll hack away at something in a branch and push it once I return to the land of the connected.

  3. Aran Mulholland reporter

    I'm moved some code over that I have to the new syntax. I keep thinking I have issues with your implementation, only to find that you have thought of an elegant solution. The start clauses use of an array of ICypherStartBit is sweet, easily extendable too. The create clause that takes a params array of objects is good as well. Great work.

  4. Log in to comment