joshuabowers / opium

An Object Parse.com Mapping technology for defining models.
MIT License
1 stars 0 forks source link

Queryable#translate_to_parse should attempt to convert value to field's type #51

Closed joshuabowers closed 8 years ago

joshuabowers commented 8 years ago

Currently, the value of a constraint added to a criteria is converted to a representation which is persistable in parse, but this practice does not take into account the field type the value is being checked against. This can lead to some wonky logic bombs:

class Model
  include Opium::Model
  field :index, type: Integer
end

Model.where( index: "5" )

In the example, "5" would get translated to a string, not to a numeric; as such, the query, when presented to parse, would likely not return valid results.

Altering the behavior should be simple enough, as Queryable#translate_to_parse should have access to the field information. However, need to verify that this does not unintentionally bork something elsewhere.