arangodb / arangodb-java-driver

The official ArangoDB Java driver.
Apache License 2.0
200 stars 93 forks source link

Arango query is flattening nested attributes #514

Closed Gajanana closed 9 months ago

Gajanana commented 11 months ago

I have document as below

{
"att1": 32,
"att2": 36,
"properties" :{
"att3" : "str1",
"att4": "str2"
}

I am passing type as BaseDocument.class in arango query

<T> ArangoCursor<T> query(String query, Class<T> type, Map<String, Object> bindVars, AqlQueryOptions options);

Earlier in 6.x . retrieving att3 was done as below

(String) ((HashMap<String, Object>)baseDocument.getAttribute("properties")).get("att3"))

Now in 7.X basedocument is flattened in returned basedocument and I have to retrieve att3 as below whereas i was expecting it to work as before matching my arango document structure

(String) (baseDocument.getAttribute("att3"))
rashtao commented 9 months ago

This is a change introduced since version 7. To get all properties as Map<String, Object> you can still use BaseDocument#getProperties().

Gajanana commented 9 months ago

What will happen if we have same attribute as nested as well as in outer layer Ex

{
"did": 32,
"att0": 36,
"properties" :{
"did" : "str1",
"att1": "str2"
}
rashtao commented 9 months ago

Thanks for clarifying, the PR above should fix it.