switchman 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5760f08a540406e8e7d546f0104c1ff8833ce7610daba34810b53ffe5caa295
4
- data.tar.gz: 4bf65b183425addbec13ae77d9e4f1e3b89244afbcf9625a7e86717e216ce778
3
+ metadata.gz: 1ffc8c73f2ac38cf0440d1e556e1c7c2af4ad8d665e40893caf76ae228bc702f
4
+ data.tar.gz: a4567920bb1cff999d77845d0de9f204826cce7ef9da1c2164802230923b56af
5
5
  SHA512:
6
- metadata.gz: e3e6467f46cb98d78e53b96b1661dbb0cfb59efd25cade9d5f1f2bde4ba067478871c42f91bd06c11c42ed6153c37fca9ef0a20555f3598f910dbda17ce9b42c
7
- data.tar.gz: eba93dc04390850eba1a7224bcf5f8fbd5b272133cbac94211c512df023a3e9a7d3951267b55bbc831012f03d443ff6705f74c601bc41a05efb389ecae4240c2
6
+ metadata.gz: 75493a10996762aacbaeb5d0ec0a8299565758eb5d1e2d8697353f02c90113b865d31253615864ea5778804830fb6abc17f50c0e5650862e6cc77319f6bc57b7
7
+ data.tar.gz: ea96557baaeed4cf99d9144cabfcadf70e6ac00024bffb16fdcc299da7298c5ec073fb9d91bdfcfbf6cd25bbd71f178bb973c7340720ba429521d94f0d4a769e
@@ -63,7 +63,7 @@ module Switchman
63
63
  %I[update_all delete_all].each do |method|
64
64
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
65
65
  def #{method}(*args)
66
- result = self.activate { |relation| relation.call_super(#{method.inspect}, Relation, *args) }
66
+ result = self.activate(unordered: true) { |relation| relation.call_super(#{method.inspect}, Relation, *args) }
67
67
  result = result.sum if result.is_a?(Array)
68
68
  result
69
69
  end
@@ -103,7 +103,7 @@ module Switchman
103
103
  end
104
104
  end
105
105
 
106
- def activate(&block)
106
+ def activate(unordered: false, &block)
107
107
  shards = all_shards
108
108
  if Array === shards && shards.length == 1
109
109
  if shards.first == DefaultShard || shards.first == Shard.current(klass.connection_classes)
@@ -124,7 +124,7 @@ module Switchman
124
124
 
125
125
  shard_results = relation.activate(&block)
126
126
 
127
- if shard_results.present?
127
+ if shard_results.present? && !unordered
128
128
  can_order ||= can_order_cross_shard_results? unless order_values.empty?
129
129
  raise OrderOnMultiShardQuery if !can_order && !order_values.empty? && result_count.positive?
130
130
 
@@ -148,8 +148,12 @@ module Switchman
148
148
  results.sort! do |l, r|
149
149
  result = 0
150
150
  order_values.each do |ov|
151
- a = l.attribute(ov.expr.name)
152
- b = r.attribute(ov.expr.name)
151
+ if l.is_a?(::ActiveRecord::Base)
152
+ a = l.attribute(ov.expr.name)
153
+ b = r.attribute(ov.expr.name)
154
+ else
155
+ a, b = l, r
156
+ end
153
157
  next if a == b
154
158
 
155
159
  if a.nil? || b.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = '3.0.3'
4
+ VERSION = '3.0.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer