ulobby / NeoEloquent

An extension of Laravel Elqouent that supports Neo4j, a native graph database
MIT License
41 stars 17 forks source link

doesntHave method does not work #36

Open joseraul opened 3 years ago

joseraul commented 3 years ago

Description:

The doesntHave method does not work. I guess other variants like whereDoesntHave, orWhereDoesntHave will not work either.

Steps To Reproduce:

Person::doesntHave("twitter")

is generating a query like

MATCH (person:`Person`), (person)-[`rel_owns_twitter`:`OWNS`]->(twitter:`Twitter`) WHERE person.deleted_at is null WITH person, count(twitter) AS twitter_count WHERE twitter_count < 1 RETURN person

It is matching on the Persons Twitter account and then requiring that there is less than one Twitter account...

raavus-funkmaster commented 3 years ago

So doesntHave appears to call has in QueriesRelationships.php. I think if the second match clause was changed to an OPTIONAL MATCH, it would fix doesntHave without breaking has.

xumng commented 2 years ago

So doesntHave appears to call has in QueriesRelationships.php. I think if the second match clause was changed to an OPTIONAL MATCH, it would fix doesntHave without breaking has.

yes. When I modify it, it can work. But where sub-clause don’t work. Because where sub-clause attach in optional match sub-clause not attach in match sub-clause. I want cypher like this: match (n) where … optional match (n)-[]-(m) with n, count(m) as cm where cm<1 return n

but it generate like this: match (n) optional match (n)-[]-(m) where … with n, count(m) as cm where cm<1 return n