cancel
Showing results for 
Search instead for 
Did you mean: 

Coercion of list to boolean is deprecated

jim_ruts
Node Link

Hi everyone,

I wanted to write a small query that gives me a list of nodes that don't have a specific relationship.

A quick google gives me results that suggest this solution:

match (p:Product) 
where not  (p)-[:HAS_CATEGORY]->(:Category)
return count(p)

This works and is simple enough, but it keeps giving me this warning:

This feature is deprecated and will be removed in future versions.
Coercion of list to boolean is deprecated. Please consider using 'NOT isEmpty(...)' instead.

I have been googling this warning but it leads me to no conclusion as to how my original query should be written.

In general I found it quite frustrating to find an answer, which is also the reason I came to the forum.
Either I do not know the right place to find these kind of things or either the documentation regarding these warnings is extremely lacking.

Thanks for reading this,

Jimmy

8 REPLIES 8

Cobra
Ninja
Ninja

Hello @jim.ruts

I know this one works:

MATCH (p:Product) 
WHERE NOT exists((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)

Could you also try:

MATCH (p:Product) 
WHERE isEmpty((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)

Regards,
Cobra

Hi cobra,

both solutions work, but they give the exact same warning regarding the coercion 😞

Cobra
Ninja
Ninja

Which version of Neo4j and Neo4j Browser are you using?
I don't get any warnings on my side for the query with exists but I get one with the isEmpty witch recommend to use exists

I am using Aura, which is using neo version 4.

I refactored my query to this:

match (p:Product) 
with
    p,
    exists((p)-[:HAS_CATEGORY]->(:Category)) as x,
where x = false
return count(p)

This removed all warning but this looks like such a nasty query for something so simple

Cobra
Ninja
Ninja

I'm not aware of the deprecation of exists() function so you can stick with this:

MATCH (p:Product) 
WHERE NOT exists((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)

jim_ruts
Node Link

Refreshing the neo browser stopped giving the warning for the exists example

MATCH (p:Product) 
WHERE NOT exists((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)

riddle me that -_-

It also stopped giving me warning on my original example.

jim_ruts
Node Link

On my test environment aura instance it does keep giving me warnings for both examples....

On my dev environment aura instance it does not....

Cobra
Ninja
Ninja

Well, I guess you should report that, must be a bug.