Closed giudicelli closed 3 years ago
Hello Giudicelli,
Thank you for raising this issue. This was a conscious design decision I had to make when developing the library. It is explained by example here.
It is because a php array can either represent a map or list in neo4j. When the array is filled it is easy to guess: 0 indexed arrays are lists and string indexed arrays are objects. The question arises: what does an empty array represent?
Thus, the ParameterHelper
was born. Using ParamaterHelper::asList([])
makes the intent explicit and is guaranteed to work.
That being said: I think you have a point. An empty array shouldn't default to an empty map, but to an empty list. I will fix this :+1:
Have a nice sunday!
This behaviour is now enforced in version 1.3.2 :)
Thanks :)
Hello, I'm using version 1.3.1.
When runing a simple update with an empty array field, the client transforms an empty array into a stdClass. Which gets rejected with the following message: "Property values can only be of primitive types or arrays thereof"
Query is: MATCH (from:Dog), (to:Dog) WHERE id(from) = $from_id AND id(to) = $to_id CREATE (from)-[breeded:BREEDED]->(to) SET breeded += $breeded_properties RETURN id(breeded) AS id
Parameters are: [ 'from_id' => 1, 'to_id' => 2, 'breeded_properties' => [ 'issues' => [] ] ]
The issue comes from: ParameterHelper::emptyDictionaryToStdClass `
`
Why would an empty array be transformed into a stdClass and not kept as an array?