Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cypher] REMOVE inside MERGE ON MATCH throws InvalidSyntaxException #6172

Open
ikwattro opened this issue Jan 3, 2016 · 7 comments
Open

Comments

@ikwattro
Copy link
Contributor

ikwattro commented Jan 3, 2016

Hi,

First of all Happy New Year !!!!

Use case : Remove a label to a node inside a MERGE ON MATCH:

Based on the default console.neo4j.org graph :

MERGE (n:Crew {name:"Morpheus"}) 
ON MATCH REMOVE n:Crew


Error: Invalid input 'R': expected whitespace, comment or SET (line 1, column 44 (offset: 43))
"MERGE (n:Crew {name:"Morpheus"}) ON  MATCH REMOVE n:Crew"
@ikwattro ikwattro changed the title REMOVE inside MERGE ON MATCH throws InvalidSyntaxException [Cypher] REMOVE inside MERGE ON MATCH throws InvalidSyntaxException Jan 3, 2016
@thobe thobe added the cypher label Jan 4, 2016
@thobe
Copy link
Contributor

thobe commented Jan 4, 2016

You are right that it probably would be more friendly to let the parser accept more things in ON MATCH and ON CREATE, and then raise a semantic error instead.

The sample query is obviously not valid, even if we were to allow more types of mutations in ON MATCH and ON CREATE, since it tries to remove one of the parameters used to match the node, thus violating the invariant of MERGE.

@ikwattro
Copy link
Contributor Author

ikwattro commented Jan 4, 2016

@thobe Thanks for your reply.

To be honest, the obvious part was not really there in our team, this is the first time we hear that you can not remove parameters used to match the node. Simply because this query doesn't fail :

Query:
MERGE (n:Crew { name:"Morpheus" })
ON MATCH SET n.name = NULL


Query took 93 ms and returned no rows. 
Updated the graph - set 1 property 

@thobe
Copy link
Contributor

thobe commented Jan 4, 2016

Yes, that one should fail as well, but doesn't.

@ikwattro
Copy link
Contributor Author

ikwattro commented Jan 4, 2016

Thanks, good to know then.

So it turns out to be more a feature request at the end, my initial application use case is the following :

MERGE (n:PullRequest {zid: {zid} })
ON MATCH REMOVE n:OpenedPullRequest, n:ClosedPullRequest

@thobe
Copy link
Contributor

thobe commented Jan 4, 2016

That looks a lot more sensible, and I can understand the desire to want to do that.

You could of course just REMOVE those labels in both the case of the node being matched and in the case of it being created, the effect would be the same: that the node does not have those labels, regardless of whether it had them before or not.

MERGE (n:PullRequest {zid: {zid} })
REMOVE n:OpenedPullRequest, n:ClosedPullRequest

@thobe thobe added the feature label Jan 4, 2016
@ikwattro
Copy link
Contributor Author

ikwattro commented Jan 4, 2016

Sure yes.

@mvoila
Copy link

mvoila commented May 23, 2023

I fall in the same use-case.
Is it implemented now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants