You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing some strange behavior when trying to AND multiple fields with the same name - the last one in wins, and it's because of the use of a LinkedHashMap in MongodbSerializer.
My expectation: startsWithIgnoreCase(somefield, startValue) && endsWithIgnoreCase(somefield, endValue) should result in a mongo query that includes both restrictions.
The reality: startsWithIgnoreCase(somefield, startValue) && endsWithIgnoreCase(somefield, endValue) results in a mongo query with only the last restriction on somefield.
Is my expectation incorrect? Is there another way to achieve this query? Or is this a defect?
Reproduction
Suppose you have a predicate whose String representation is:
As the expression is processed by handle, visit(Operation<?> expr, Void context) (source) is hit. Visit leverages BasicDBObject (extends BasicBSONObject, extends LinkedHashMap <String, Object>) for the AND scenario. As the expression is processed, the conditions are put in this structure: here. Because this is not a multi-value HashMap, if multiple conditions exist for the same key, then only the last one will end up in the resulting BasicDBObject.
Consequently, information is lost in the serialization of the expression to the MongoDB query.
The text was updated successfully, but these errors were encountered:
I'm seeing some strange behavior when trying to AND multiple fields with the same name - the last one in wins, and it's because of the use of a LinkedHashMap in MongodbSerializer.
My expectation: startsWithIgnoreCase(somefield, startValue) && endsWithIgnoreCase(somefield, endValue) should result in a mongo query that includes both restrictions.
The reality: startsWithIgnoreCase(somefield, startValue) && endsWithIgnoreCase(somefield, endValue) results in a mongo query with only the last restriction on somefield.
Is my expectation incorrect? Is there another way to achieve this query? Or is this a defect?
Reproduction
Suppose you have a predicate whose String representation is:
...and you create a MongodbQuery and invoke MongodbQuery.where(predicate). Then you invoke list() on the query.
MongodbQuery.list() calls MongodbQuery.createCursor() which in turn leverages MongodbSerializer.handle(predicate) - source.
The String representation of the where value in QueryMetadata is:
As the expression is processed by handle, visit(Operation<?> expr, Void context) (source) is hit. Visit leverages BasicDBObject (extends BasicBSONObject, extends LinkedHashMap <String, Object>) for the AND scenario. As the expression is processed, the conditions are put in this structure: here. Because this is not a multi-value HashMap, if multiple conditions exist for the same key, then only the last one will end up in the resulting BasicDBObject.
Consequently, information is lost in the serialization of the expression to the MongoDB query.
The text was updated successfully, but these errors were encountered: