I have the following statement:
CREATE (u:User {externalId:'59b4c855-6ce0-495e-b2eb-2816f498f479', email:'create@some.com', name:'Cr Ate', enabled:true })
WITH u MATCH (g:UserGroups) WHERE g.code IN ['admin', 'product']
CREATE (u)-[:hasRole]->(g)
WITH u MATCH (p:Party) WHERE elementId(p) IN ['4:d2fb2e08-d9a8-4ace-b7b6-305175ee9551:204']
CREATE (u)-[:worksFor]->(p)
Any idea why the :worksFor relationship is created twice?
Yes, it is because you have two values of 'g' matched, so the rows after the CREATE (u)-[:hasRole]->(g)
are as follows:
u, g with g.code = 'admin'
u, g with g.code = 'product
thus, after the with u
, the rows are:
u
u
This causes, the CREATE (u)-[:worksFor]->(p)
to execute twice.
You can fix it by replacing the second 'with u' with:
with distinct u
Thanks !
I'm starting to feel I will need to invite you when I do the system's demo to the W3C :D
When is that. I am going to want to watch to see if you make me proud.
at some point in March - i'll let you know
1 Like