I’m trying to change the property type of a node (from string to array):
match(d:Diagnosis) set d.diagnosis_tool = [d.diagnosis_tool] return d
but it its throwing this error:
Neo.ClientError.Statement.TypeError: Property values can only be of primitive types or arrays thereof
I don’t think it likes that the array only has one element, any ideas on how to achieve this?
Arrays cannot contain arrays - the message could perhaps be worded more clearly but it seems that in this particular case diagnosis_tool is already an array, and you're trying to create a nested array.
Example:
neo4j> create (d:Diagnosis) SET d.diagnosis_tool=[[1]] RETURN d;
Property values can only be of primitive types or arrays thereof
To limit your query to only those that are currently strings and not arrays, you might do something like this:
match (d:Diagnosis) where d.diagnosis_tool + '' = d.diagnosis_tool
WITH d as hasStringDiagnosisTool
SET d.diagnosis_tool = [hasStringDiagnosisTool.diagnosis_tool]
RETURN count(d);
2 Likes