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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa20d460683c12b9e6528f0956c83dec5fadcc4247d551fbd84361757d5452a0
4
- data.tar.gz: 79a6a917b940d6e0bc5b10288f757d002635526e083f3c123698976fb5e96483
3
+ metadata.gz: 95fe539c72b87f09c12d626ca172f256d0d45c12f848f41ce69620533c24edc0
4
+ data.tar.gz: 868a2413f9ff449ee4dcb95df7addff77276fe7c67f70868be593524051c38a9
5
5
  SHA512:
6
- metadata.gz: 55aca398595c2fda0e32f4aa35e10f42ded64d3154d1dd9bb5cee8f0a0682d61317f8486b156e2722ed3c381dd6cc42710729e19d859b3ade543991469464835
7
- data.tar.gz: 4b5bfb169f36aa3a69f716195316941f648d8b06ae3c9a9f09c5b5835dd67005ddbc7fe7cbe864b278aefeb3abdeaa8f65292f00dcd29c4cf1011c4e852bec64
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.respond_to?(ov.expr.name)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "2.0.11"
4
+ VERSION = "2.0.12"
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: 2.0.11
4
+ version: 2.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer