lib/mongoid/association/referenced/has_one/buildable.rb in mongoid-7.3.5 vs lib/mongoid/association/referenced/has_one/buildable.rb in mongoid-7.4.0

- old
+ new

@@ -1,16 +1,13 @@ # frozen_string_literal: true -# encoding: utf-8 module Mongoid module Association module Referenced class HasOne # The Builder behavior for has_one associations. - # - # @since 7.0 module Buildable # This method either takes an _id or an object and queries for the # inverse side using the id or sets the object after clearing the # associated object. @@ -47,10 +44,12 @@ associated.substitute(nil) end end def query_criteria(object, base) - crit = klass.where(foreign_key => object) + crit = klass.criteria + crit = crit.apply_scope(scope) + crit = crit.where(foreign_key => object) with_polymorphic_criterion(crit, base) end def execute_query(object, base) query_criteria(object, base).limit(1).first(id_sort: :none)