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

Polymorphic association should use type as well as id in finders

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

      With these models:

      class Entity
        include Mongoid::Document
        has_one :search_index, :as => :searchable
      end
      class EntityRef
        include Mongoid::Document
        has_one :search_index, :as => :searchable
      end
      class SearchIndex
        include Mongoid::Document
        belongs_to :searchable, :polymorphic => true
      end
      

      If I do EntityRef.first.search_index, I see this in the log:

      MONGODB app_development['search_indices'].find(

      {"searchable_id"=>"/m/011p0w"}

      )

      The find is using only the polymorphic id field, not type. I think it should!

            Assignee:
            Unassigned Unassigned
            Reporter:
            bensymonds Ben Symonds
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: