-
Notifications
You must be signed in to change notification settings - Fork 454
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
Morphia's Criteriacontainer overwrites previously set "$or" statement #1278
Comments
Update: I have your bug fixed but it broke a few other tests. I'm investigating. |
I've fixed this bug but the actual shape of the document is different than you're expecting. Because the default "join" operation on document elements is an {
"$or": [
{
"fieldA": "a"
},
{
"fieldB": "b"
}
],
"fieldC": "c",
"$or": [
{
"fieldD": "d"
},
{
"fieldE": "e"
}
]
} |
Thank you! |
Of, course! Apologies for the delay. |
@evanchooly , the response from the above query is |
Are you on 1.5.2? |
@evanchooly 1.3.2.. please help if there is any workaround or fix available for this. Or let us know if there is better way of query building to avoid this issue. |
@tungnduong , can you please share if this issue is resolved for you? what is the morphia version you are using? |
Well, the issue is marked as fixed in 1.5.0 so if you're not on at least that version, you're not going to have the fix. |
Thanks @evanchooly .. But i see only 1.3.2 is the latest on Maven. |
@evanchooly thank you so much. That helps! |
I am using Morphia's Query api, and found that my "or" expression is getting overwritten when the expression takes a certain shape. The full expression that I tried to craft was:
Here's how I'm building the query:
The resultant query's toString() form :
{ query: { "$or" : [{ "fieldD" : "D" }, { "fieldE" : "E" }], "fieldC" : "C" }
It's missing the section, "$or: [ {fieldA: A}, { fieldB: B} ]".
I understand that the api modifies the internal state of the query object, and so I suspect that perhaps I'm not using the API correctly. If so, could you please provide some guidance on how my original expression could be built programmatically using the Query object?
I digged into Morphia's CriteriaContainerImpl.java, and saw that the addTo(final DBObject obj) method descends into the nested expression and passes the running DBObject:
Then, when it starts evaluating the child "$or" expression, it replaces the pre-existing "$or" stored in the propagated DBObject:
Thanks for your time. If this is not the proper place to be posting this, then please kindly direct me to where I should go for these type of questions.
The text was updated successfully, but these errors were encountered: