-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: 7.0.2, 6.4.2
-
Component/s: Associations
-
None
The primary_key and foreign_key are not respected when using unscoped for some reason.
Example:
When I use this query, it correctly generates the criteria.
@company.emails #<Mongoid::Criteria selector: {"h"=>false, "d"=>"cacheventures.com"} options: {} class: Crawler::Email embedded: false>
However, when I use this query, it incorrectly generates the criteria
@company.emails.unscoped <Mongoid::Criteria selector: {"d"=>"5b90592edf119da720bba8cc"} options: {} class: Crawler::Email embedded: false>
Below is an example of my models
class Company include Mongoid::Document has_many :emails, primary_key: :w, foreign_key: :d, class_name: 'Crawler::Email' field :w, as: :website, type: String end
class Email include Mongoid::Document belongs_to :company, primary_key: :w, foreign_key: :d, class_name: 'Crawler::Company' field :d, as: :domain, type: String field :h, as: :hidden, type: Boolean, default: false default_scope -> { where(hidden: false) } end
- depends on
-
MONGOID-4642 Document primary_key/foreign_key
-
- Closed
-
- links to