switchman 2.0.11 → 2.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/switchman/active_record/relation.rb +6 -4
- data/lib/switchman/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95fe539c72b87f09c12d626ca172f256d0d45c12f848f41ce69620533c24edc0
|
4
|
+
data.tar.gz: 868a2413f9ff449ee4dcb95df7addff77276fe7c67f70868be593524051c38a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e062c3284a76b55aeb342ad56b5f662a4c096af2725dbd24d7f6c8381a66c7d57bdee7ee4143c1283540aeb32acc503eab80202087a173b85437e272353521
|
7
|
+
data.tar.gz: f1b74516b612f38b4e0974948561497d5dcd0b61a2bf182d134ddad0e9d0428eaeccbb2e1376cca76d0b4d0fb9b743f06121f66263654966a6cdd06ab656a583
|
@@ -62,7 +62,7 @@ module Switchman
|
|
62
62
|
%I{update_all delete_all}.each do |method|
|
63
63
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
64
64
|
def #{method}(*args)
|
65
|
-
result = self.activate { |relation| relation.call_super(#{method.inspect}, Relation, *args) }
|
65
|
+
result = self.activate(unordered: true) { |relation| relation.call_super(#{method.inspect}, Relation, *args) }
|
66
66
|
result = result.sum if result.is_a?(Array)
|
67
67
|
result
|
68
68
|
end
|
@@ -97,7 +97,7 @@ module Switchman
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
def activate(&block)
|
100
|
+
def activate(unordered: false, &block)
|
101
101
|
shards = all_shards
|
102
102
|
if (Array === shards && shards.length == 1)
|
103
103
|
if shards.first == DefaultShard || shards.first == Shard.current(klass.shard_category)
|
@@ -118,7 +118,7 @@ module Switchman
|
|
118
118
|
|
119
119
|
shard_results = relation.activate(&block)
|
120
120
|
|
121
|
-
if shard_results.present?
|
121
|
+
if shard_results.present? && !unordered
|
122
122
|
can_order ||= can_order_cross_shard_results? unless order_values.empty?
|
123
123
|
raise OrderOnMultiShardQuery if !can_order && !order_values.empty? && result_count.positive?
|
124
124
|
|
@@ -142,7 +142,9 @@ module Switchman
|
|
142
142
|
results.sort! do |l, r|
|
143
143
|
result = 0
|
144
144
|
order_values.each do |ov|
|
145
|
-
if l.
|
145
|
+
if !l.is_a?(::ActiveRecord::Base)
|
146
|
+
a, b = l, r
|
147
|
+
elsif l.respond_to?(ov.expr.name)
|
146
148
|
a = l.send(ov.expr.name)
|
147
149
|
b = r.send(ov.expr.name)
|
148
150
|
else
|
data/lib/switchman/version.rb
CHANGED