Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1516

Mongoid try to serialize values of complex criteria for customs serialized fields

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.4.0
    • Affects Version/s: None
    • Component/s: None

      I've create following custom type

      class LatLng
        include Mongoid::Fields::Serializable
      
        def deserialize(object)
          { :lat => object[1], :lng => object[0] }.with_indifferent_access
        end
      
        def serialize(object)
          latlng = object.with_indifferent_access
          [ latlng[:lng], latlng[:lat] ]
        end
      end
      

      Running of this query

      field :from_latlng, type: LatLng

      doc.where(:from_latlng =>

      {"$nearSphere" => [lng, lat], "$maxDistance" => radius / EARTH_RADIUS}

      ) will cause exception due to it tries to serialize params from complex criteria hash using my custom type.

            Assignee:
            Unassigned Unassigned
            Reporter:
            azakharov Alexey Zakharov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: