Coercion of list to boolean is deprecated

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

Hello @jim_ruts :slight_smile:

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 :(

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 :slight_smile:

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

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)

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.

1 Like

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

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

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