-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
MONGOID-5408 proposes to add a "Wrapper to skip evolution while querying".
As a refinement to this ticket, the wrapper should evolve values so they are compatible with the Mongo Ruby Driver, however, the evolution should be done in a field-independent manner.
Known cases where this is useful:
- BigDecimal "raw values" should evolve to BSON::Decimal128.
- Range values should mongoize (not evolve) to their { min: 1, max: 3 } form.
- Array / Hash should recursively evolve to cover BigDecimal / Range members.
In most cases evolve returns the same object (Integer -> Integer, String -> String, etc.) so the implementation should probably evolve all raw values.
To illustrate how this works, consider the example:
class Person field :name, as: String field :age, as: Integer end Person.where(name: Mongoid::RawValue(BigDecimal(42))) #=> This should query for name: 42 as BSON::Decimal128 # Note that the field type String is ignored. Person.where(age: 20..30) #=> This queries for age $gte: 20, $lte: 30. # (This is the existing behavior) Person.where(age: Mongoid::RawValue(20..30)) #=> this queries for age equals the Hash literal { min: 20, max: 30 }
- duplicates
-
MONGOID-5408 Wrapper to skip evolution while querying
- Closed