Data format issue

Hello everyone,

does anybody else have an issue when we return a map at the end of a query, if one property is set to (empty array) ? instead of getting php gets a {} (which is not an array)

Thanks

I have not. Can you provide your query and an example?

Hello Gary, sorry for this late late reply...

We have a query like that, which return a map :

Match (r:Restaurant) where r.code = 123
With r
Optional match (r)-[HAS_ROOM]->(ro:Room)
collect(CASE WHEN ro IS NULL THEN NULL ELSE {room:ro} END ) as roomDetailList
Return 
{restaurant: r.code,
  room: roomDetailList} as restaurantRoomDetails

If the restaurant has no room, then the roomDetailList is an empty list

When the query is executed through the php driver, and when our api converts the query result as a json output, we get this data structure

{restaurant: 123,
  room: {} }

but actually we would be expecting this :

{restaurant: 123,
  room: []  }

have you ever got similar issues?
thanks

I have not seen that behavior. I use the java driver and I have not had that issue. It works as expected when executed in the Neo4j browser.

BTW- you can refactor the code a little. I find this a cleaner version.

Match (r:Restaurant) where r.code = 123
Return 
{
  restaurant: r.code,
  room: [(r)-[:HAS_ROOM]->(ro:Room) | {room:ro}]
} as restaurantRoomDetails

With related data:

Without related data:

Yes indeed, no such issue with the java driver. Only with php. Thanks Gary for the time you spent trying this!

1 Like