lib/mongoid/association/referenced/has_one/buildable.rb in mongoid-7.1.11 vs lib/mongoid/association/referenced/has_one/buildable.rb in mongoid-7.2.0.rc1
- old
+ new
@@ -44,10 +44,10 @@
crit = klass.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)
+ query_criteria(object, base).limit(1).first(id_sort: :none)
end
def with_polymorphic_criterion(criteria, base)
if polymorphic?
criteria.where(type => base.class.name)