Issue #45 resolved

Cyper should allow for flexible order of operators

Aran Mulholland avatarAran 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
DELETE r
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

    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. Tatham Oddie

    There's some progress in the issue-45 branch. Keen for any feedback: it's a bit of convoluted plumbing required to evolve it in rather than smashing it all in as one horrendous changeset.

  4. Tatham Oddie

    So far, it looks like the only casualty is needing to kill off AddStartPoint, which doesn't make much sense any more. The rest is migrating across nicely.

  5. Aran Mulholland

    Looks like it's going really well. I have had a look at some of the changes and made some comments. I'll look into it more in the coming days and start using it.

  6. Aran Mulholland

    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.

  7. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.