question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for $ projection

See original GitHub issue

Hello, 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
bwaldvogelcommented, Nov 17, 2019

I’ve just released version 1.23.0.

1reaction
Maxehcommented, Nov 12, 2019

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Projections Central
Forecasting America's Industry and Occupational Employment. to help people with career choices and business decisions ...
Read more >
Projection | Psychology Today
These questions can help you explore whether and why you may have been projecting. How can you tell if someone is projecting on...
Read more >
What Is Projection as a Defense Mechanism? - Verywell Mind
Projection is when one sees the traits that they find unacceptable in themselves in others. Learn about the origin and impact of the...
Read more >
Central support projection and support projection
1 Answer 1 ... The usual definition, for a state ω on A, would be suppω=I−⋁{p∈A: projection, ω(p)=0}. The central version would be...
Read more >
Psychological Projection: Dealing With Undesirable Emotions
Psychological projection is a defense mechanism people subconsciously employ in order to cope with difficult feelings or emotions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found