New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1387 criteria reader doesn't respect getter prefixes #1417
base: master
Are you sure you want to change the base?
1387 criteria reader doesn't respect getter prefixes #1417
Conversation
This is a bit draft location of the tests, most probably these tests should be relocated or deleted.
…athNaming.defaultNaming() Using PathNaming.defaultNaming() in MongoPathNaming will result in all property names being the member path.
@asereda-gs can you check this when you have time. I would just merge it, but need to understand how well it addresses the underlying problem and if it causes any issues / incompatibilities |
-Use mongo-java-server to allow github actions to run and to follow projects suggestions. -Removed duplication in code. -Added javadoc
@elucash let me check this PR on weekend. Sorry was busy lately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello.
Thank you for this PR!
I'm thinking if allowing users to register their own PathNaming
instance in MongoSetup
would be a more flexible strategy?
Overall PathNaming
needs to be better integrated with Gson/Jackson/Bson serializations.
I assume this issue also affects ElasticSearch backend?
Ideally one should re-use existing BSON |
I have prepared some ideas in a separate branch: https://github.com/immutables/immutables/tree/jackson-pathnaming it needs some more work |
Please take a look at 3fb8e3 and let me know if it works for you. |
Hello and thank you for your response.
That would indeed give flexibility to more advanced users, giving more control over the PathNaming.
I would also agree, the ideal solution should use the same functions that are used to serialize an Entity in JSON. If the Codec is provided it could be possible to use it in queries.
I have been testing the solution provided and will come back with feedback. |
This is an attempt to fix autogenerated Criteria that do not work in
find()
in theMongoBackend
an issue also described in #1387 with more details.The conversion from the property names to the MongoDB fields seems to take place in
MongoSession.java
.There the
_id
property was handled individually and all other properties were delegated toPathNaming.defaultNaming()
which returned the path as a field name. This did not work in MongoDB filter queries. As for example it returnedgetDescription
instead ofdescription
and the filter query required the field name, beingdescription
.Replacing the
PathNaming.defaultNaming()
with theJavaBeanNaming()
provides accurate field name transitions.2 tests have also been included that test that
find()
works with theID
, with a getter of the formgetProperty()' and with a getter of the form
property()'. I named properties more specifically to facilitate any potential future references.PS: This PR solves some cases and improves the situation, but more changes should be examined. For instance taking into account the
@JsonProperty
annotation.