Support for $ projection
See original GitHub issueHello, first of all thanks for the great work 😃
We are using a custom query in our project with projection, but it seems that mongo-java-server does not support such kind of projection. The query looks for objects which have a specific nested object in an array and the query returns the object with only the matching nested object in the array. It looks like this:
@Query(value = "{ 'states': { $elemMatch: { 'state': { $eq: \"INSTALLED\" }, 'internalID': { $eq: ?0 } } } }", fields = "{ 'states.$': 1, 'serialnumber': 1 }")
List<MyObject> findWithCustomQuery(String internalID);
So if we have a object like this:
object1:
|---serialnumber: 1234
|---states:
|---[0]
|---state: INSTALLED
|---internalID: abc123
|---[1]
|---state: UPDATE
|---internalID: abc456
object2:
|---serialnumber: 5678
|---states:
|---[0]
|---state: UPDATE
|---internalID: abc123
|---[1]
|---state: UPDATE
|---internalID: abc456
and the query is done with internalID abc123 only the first object containing an array with the matching object should be returned. This works in mongo 3.6, but not with mongo-java-server. If I use mongo-java-server all fields of the array are set to null and all objects in the array are returned. So the expected result would be:
object1:
|---serialnumber: 1234
|---states:
|---[0]
|---state: INSTALLED
|---internalID: abc123
But we actually get:
object1:
|---serialnumber: 1234
|---states:
|---[0]
|---state: null
|---internalID: null
|---[1]
|---state: null
|---internalID: null
Any help is appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
I’ve just released version
1.23.0
.@bwaldvogel I have created a fat jar file and installed it to my local maven repo and it worked.
The bug seems to be fixed and the correct data is loaded. When do you think will the new version be available in the maven repository?