microsoft / spring-data-cosmosdb

Access data with Azure Cosmos DB
MIT License
94 stars 64 forks source link

Query for nested property causes wrong param identifier in query #221

Closed jannhendrik closed 6 years ago

jannhendrik commented 6 years ago

For

class User {
  ... 
  private Person person;
   ...
}

class Person {
   ....
   private ZonedDateTime birthdatetime;
   ....
}
class SomeRepo {
      List<User> findByPerson_Birthdatetime(@Param("birthdatetime ") ZonedDateTime birthdatetime )
}

the following query is generated.

"SELECT * FROM ROOT r WHERE r.person.birthdatetime > @person.birthdatetime "

Which throws an exception because paramter names 'must conform to @ followed by a valid identifier'.

Incarnation-p-lee commented 6 years ago

@jannhendrik Thanks for your issue. As National festival, sorry for late response. I will try to reproduce this from my env.

kamalhashi commented 5 years ago

Hi, Is this issue has been solved ? I'm still getting the same error

"message": "com.microsoft.azure.documentdb.DocumentClientException: Message: {\"Errors\":[\"Invalid query. Specified parameter name '@identifications.unitId' is invalid. Parameter names should be in the format of symbol '@' followed by a valid identifier. E.g. @param1\"]}\r\nActivityId: 4b21e05f-0fa6-40e0-ab22-2ae5755a2515, Request URI: /apps/7da5b391-0f9a-491d-ba27-5ec488c34aff/services/0435fed3-5839-4b67-925d-24552c7e0aea/partitions/d556cadf-1ef4-404b-86c1-9ba2403a1831/replicas/131824899814612693p, RequestStats: \r\nRequestStartTime: 2018-11-27T14:54:50.9400203Z, Number of regions attempted: 1\r\nResponseTime: 2018-11-27T14:54:50.9500049Z, StoreReadResult: StorePhysicalAddress: rntbd://10.0.0.103:14000/apps/7da5b391-0f9a-491d-ba27-5ec488c34aff/services/0435fed3-5839-4b67-925d-24552c7e0aea/partitions/d556cadf-1ef4-404b-86c1-9ba2403a1831/replicas/131824899814612693p, LSN: 11516, GlobalCommittedLsn: 11516, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, IsGone: False, IsNotFound: False, IsInvalidPartition: False, RequestCharge: 1, ItemLSN: -1, SessionToken: 11516, ResourceType: Document, OperationType: Query\r\n, SDK: Microsoft.Azure.Documents.Common/2.1.0.0, StatusCode: BadRequest" } I have similar below code

`class User { ... private Person person; ... }

class Person { .... private String name; .... }`

Incarnation-p-lee commented 5 years ago

@kweheliye Thanks for issue this, we should fix this issue and add integration test for that. Could you please provide more information about this ? Like which version of spring-data-cosmosdb, ?

kamalhashi commented 5 years ago

I'm not on my deskright now, but I think 2.0.5 with spring boot 2.0.2.RELEASE.

However I was able to fetch the child object or the nested object only by passing the nested object as parameter along with the nested object's properties fully populated.

So passing object who it's properties partially filled in will return empty.

Is there a workaround while the issue is being fixed ?

Incarnation-p-lee commented 5 years ago

@kweheliye the 2.0.5 version may not contains that fix, it merged into master at 11 Oct. And 3.0.0.M1 is migrate to new SDK branch out early Oct also missed that fix. We would like to release new version like for this.