Fix subquery errors triggered by #warn_invalid_order_cycles

This commit is contained in:
Matt-Yorkley
2020-01-12 12:51:49 +01:00
parent 57ca1d54bb
commit 59ebfb9bd4
3 changed files with 3 additions and 3 deletions

View File

@@ -97,7 +97,7 @@ module Spree
def active_distributors_not_ready_for_checkout
ocs = OrderCycle.managed_by(spree_current_user).active
distributors = ocs.includes(:distributors).map(&:distributors).flatten.uniq
Enterprise.where('enterprises.id IN (?)', distributors).not_ready_for_checkout
Enterprise.where(id: distributors.map(&:id)).not_ready_for_checkout
end
def active_distributors_not_ready_for_checkout_message(distributors)

View File

@@ -115,7 +115,7 @@ class Enterprise < ActiveRecord::Base
scope :not_ready_for_checkout, lambda {
# When ready_for_checkout is empty, return all rows when there are no enterprises ready for
# checkout.
ready_enterprises = Enterprise.ready_for_checkout.select('enterprises.id')
ready_enterprises = Enterprise.ready_for_checkout.pluck(:id)
if ready_enterprises.present?
where("enterprises.id NOT IN (?)", ready_enterprises)
else

View File

@@ -63,7 +63,7 @@ class OrderCycle < ActiveRecord::Base
if user.has_spree_role?('admin')
scoped
else
where('coordinator_id IN (?)', user.enterprises.map(&:id))
where(coordinator_id: user.enterprises)
end
}