Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-21-2021 10:36 PM
I am attaching a query, in this query we need to convert the empty strings as NULL values to concat the strings to form comma-separated strings.
match (d:dpComponent)
call apoc.do.case([
d.componentId="",'SET d.componentId = null return d',
d.componentName="",'SET d.componentName = null return d',
d.componentKey="",'SET d.componentKey = null return d'],
'',{d:d})
YIELD value
RETURN
value.d.componentId as ID,
value.d.componentName as Name,
value.d.componentKey as Key
order by ID
03-24-2021 01:50 PM
Keep in mind that there is really no such thing as a null value for a property, it's the same as non-existence, so setting a property to null is the same as removing it.
Likewise, returning the value for a property that doesn't exist will return null.
If you want to handle all of these at once, then usage of a map for the +=
operation will overwrite properties, so it's just a matter of generating a map that will set the relevant properties to null if they're the empty string, or otherwise leave them alone (if they aren't the empty string, it will just set them to their current value):
match (d:dpComponent)
WITH d, {componentId: CASE WHEN d.componentId = "" THEN NULL ELSE componentId END,
componentName: CASE WHEN d.componentName = "" THEN NULL ELSE componentName END,
componentKey: CASE WHEN d.componentKey = "" THEN NULL ELSE componentKey END} as map
SET d += map
RETURN
d.componentId as ID,
d.componentName as Name,
d.componentKey as Key
order by ID
All the sessions of the conference are now available online