UNION, CALL and message "CALL subquery without a variable scope clause is now deprecated. Use CALL () { ... }

Hi,
following UNION - Cypher Manual I am writing my query as follows:

CALL {
  MATCH (n:SyncopeUser) 
  WITH n.id AS id, n.username AS username, apoc.convert.getJsonProperty(n, 'plainAttrs.fullname', '$.uniqueValue') AS fullname 
  WHERE (EXISTS { MATCH (n) WHERE fullname.stringValue =~ "(?i).*ino.*rossini.*"} ) 
  AND EXISTS { (n)-[]-(r:Realm) WHERE r.id IN $param0 }
  RETURN id, username 

UNION 

  MATCH (n:UMembership)-[]-(m:SyncopeUser) 
  WITH m.id AS id,m.username AS username,apoc.convert.getJsonProperty(n, 'plainAttrs.fullname', '$.values') AS fullname 
  WHERE (EXISTS { MATCH (n) WHERE fullname.stringValue =~ "(?i).*ino.*rossini.*"} ) 
  AND EXISTS { (m)-[]-(r:Realm) WHERE r.id IN $param0 }
  RETURN id, username 
}

RETURN id ORDER BY username ASC SKIP 0 LIMIT 2

The query works as expected; I am however getting the following message in the logs:

15:24:51.911 WARN  org.springframework.data.neo4j.cypher.deprecation - Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.
[...]
CALL subquery without a variable scope clause is now deprecated. Use CALL () { ... }

Could you please help me understand how the query above should be changed to reflect the new feature?
Thank you!

There is a new variable scope syntax for call subqueries that you use to pass variables to the call instead of importing with a "with" clause. You have not parameters to send, so you can use an empty parameter list.

Try the following to see if you don't get the warning:

CALL () {
  MATCH (n:SyncopeUser) 
  WITH n.id AS id, n.username AS username, apoc.convert.getJsonProperty(n, 'plainAttrs.fullname', '$.uniqueValue') AS fullname 
  WHERE (EXISTS { MATCH (n) WHERE fullname.stringValue =~ "(?i).*ino.*rossini.*"} ) 
  AND EXISTS { (n)-[]-(r:Realm) WHERE r.id IN $param0 }
  RETURN id, username 

UNION 

  MATCH (n:UMembership)-[]-(m:SyncopeUser) 
  WITH m.id AS id,m.username AS username,apoc.convert.getJsonProperty(n, 'plainAttrs.fullname', '$.values') AS fullname 
  WHERE (EXISTS { MATCH (n) WHERE fullname.stringValue =~ "(?i).*ino.*rossini.*"} ) 
  AND EXISTS { (m)-[]-(r:Realm) WHERE r.id IN $param0 }
  RETURN id, username 
}

RETURN id ORDER BY username ASC SKIP 0 LIMIT 2

@glilienfield it works like a charm, thank you!

1 Like