You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check 5 people with a property prop and a bunch of values: match (n:Person) where n.prop is not null return n.name, n.prop;
Apply transformation:
MATCH (n)
CALLapoc.refactor.normalizeAsBoolean(n,'prop',['Y','Yes'],['NO'])
WITHnORDER BYn.idRETURNn.propASprop
Property is gone on the person named Valid: match (n:Person) where n.prop is not null return n.name, n.prop;
While the labs page say "The other properties that don’t match these possibilities will be set as null." I find this behaviour at least surprising for things that are already boolean. And not in a good way surprising.
The text was updated successfully, but these errors were encountered:
michael-simons
changed the title
Normalize as boolean deletes properties.
Normalize as boolean deletes boolean properties, too.
May 24, 2023
@michael-simons After looking into the code, it seems like this is actually intentional even though it is confusing. What you need to do is
MATCH (n)
CALL apoc.refactor.normalizeAsBoolean(n,'prop',['Y','Yes',true],['NO',false])
WITH n
ORDER BY n.id
RETURN n.prop AS prop
Since there can be people relying on the old behaviour, we decided not to change it, but we will update the documentation to explicitly mention that you need to include true and false in the parameters if you want to keep them
Expected Behavior (Mandatory)
Normalize to boolean should normalise string properties to boolean, not delete existing boolean properties.
Actual Behavior (Mandatory)
When a property on a node is already
boolean
it will be deleted by the normalisation.How to Reproduce the Problem
Simple Dataset (where it's possibile)
Steps (Mandatory)
prop
and a bunch of values:match (n:Person) where n.prop is not null return n.name, n.prop;
Valid
:match (n:Person) where n.prop is not null return n.name, n.prop;
While the labs page say "The other properties that don’t match these possibilities will be set as null." I find this behaviour at least surprising for things that are already boolean. And not in a good way surprising.
The text was updated successfully, but these errors were encountered: