Skip to content

Commit

Permalink
Merge pull request #2921 from aitbw/nebulab/fix-dangerous-query-method
Browse files Browse the repository at this point in the history
Fix deprecation warning for Spree::Shipment#reverse_chronological scope
  • Loading branch information
kennyadsl authored Nov 22, 2018
2 parents 717a800 + dc248d8 commit b00b007
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class Shipment < Spree::Base
scope :trackable, -> { where("tracking IS NOT NULL AND tracking != ''") }
scope :with_state, ->(*s) { where(state: s) }
# sort by most recent shipped_at, falling back to created_at. add "id desc" to make specs that involve this scope more deterministic.
scope :reverse_chronological, -> { order('coalesce(spree_shipments.shipped_at, spree_shipments.created_at) desc', id: :desc) }
scope :reverse_chronological, -> {
order(Arel.sql("coalesce(#{Spree::Shipment.table_name}.shipped_at, #{Spree::Shipment.table_name}.created_at) desc"), id: :desc)
}

scope :by_store, ->(store) { joins(:order).merge(Spree::Order.by_store(store)) }

# shipment state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
Expand Down

0 comments on commit b00b007

Please sign in to comment.