switchman 1.5.11 → 1.5.13

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
  SHA1:
3
- metadata.gz: a6e7bdc0136ef65434df5ec4cd150a80ea3ff48a
4
- data.tar.gz: 3ac58daa39eb55bc3b1ea743d6995072acf91ab2
3
+ metadata.gz: c25757a3ecb19cfba0a82adbe3fa0e881d58c302
4
+ data.tar.gz: 13b9c2b34b8f9f562b84a19bb43865436e4bdff5
5
5
  SHA512:
6
- metadata.gz: 792fbbdedbdc2028003b2eda51934e9c8821d0fd479c7e5da119c453d3696f232a752bcef868c291f3cc4b31a7acf560cadfda50c4bd48df4aa64826eb27b1f3
7
- data.tar.gz: 1310d057a27d42f01a7dbad5b70d6ac3be09b42aa06f3abd71f3c933260a387b3542e97a2ca5754b0bd89ee65f0689f7314f8717e5a8929c676dad24879c5ef3
6
+ metadata.gz: 0382c38297c9ef9cb15622fbaf342870942b660d1be4131ad085f2d891f6d38e79f5c584aba8866306f18a813703beaeafe675685f483fa75aae9de1cb1d35db
7
+ data.tar.gz: 03a4c27d1596eac4ced134b60abe9a2d05970a74d89c0040b8fdb3bacd4999e785c4f3d6ee14e9aa55943dfe6574d3c725b5a3b0be2c9f8d98080133de3fc2f7
@@ -46,6 +46,19 @@ module Switchman
46
46
  # moved to WhereClauseFactory#build in Rails 5
47
47
  def build_where(opts, other = [])
48
48
  case opts
49
+ when String, Array
50
+ values = Hash === other.first ? other.first.values : other
51
+
52
+ values.grep(ActiveRecord::Relation) do |rel|
53
+ # serialize subqueries against the same shard as the outer query is currently
54
+ # targeted to run against
55
+ if rel.shard_source_value == :implicit && rel.primary_shard != primary_shard
56
+ rel.shard!(primary_shard)
57
+ end
58
+ self.bind_values += rel.bind_values if ::Rails.version < '4.2'
59
+ end
60
+
61
+ [@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]
49
62
  when Hash, ::Arel::Nodes::Node
50
63
  predicates = super
51
64
  infer_shards_from_primary_key(predicates) if shard_source_value == :implicit && shard_value.is_a?(Shard)
@@ -5,15 +5,27 @@ module Switchman
5
5
 
6
6
  def build(opts, other = [])
7
7
  case opts
8
- when Hash, ::Arel::Nodes::Node
9
- where_clause = super
10
- predicates = where_clause.send(:predicates)
11
- @scope.send(:infer_shards_from_primary_key, predicates, where_clause.binds) if @scope.shard_source_value == :implicit && @scope.shard_value.is_a?(Shard)
12
- predicates = @scope.transpose_predicates(predicates, nil, @scope.primary_shard, false, where_clause.binds) if @scope.shard_source_value != :explicit
13
- where_clause.instance_variable_set(:@predicates, predicates)
14
- where_clause
15
- else
16
- super
8
+ when String, Array
9
+ values = Hash === other.first ? other.first.values : other
10
+
11
+ values.grep(ActiveRecord::Relation) do |rel|
12
+ # serialize subqueries against the same shard as the outer query is currently
13
+ # targeted to run against
14
+ if rel.shard_source_value == :implicit && rel.primary_shard != @scope.primary_shard
15
+ rel.shard!(@scope.primary_shard)
16
+ end
17
+ end
18
+
19
+ super
20
+ when Hash, ::Arel::Nodes::Node
21
+ where_clause = super
22
+ predicates = where_clause.send(:predicates)
23
+ @scope.send(:infer_shards_from_primary_key, predicates, where_clause.binds) if @scope.shard_source_value == :implicit && @scope.shard_value.is_a?(Shard)
24
+ predicates = @scope.transpose_predicates(predicates, nil, @scope.primary_shard, false, where_clause.binds) if @scope.shard_source_value != :explicit
25
+ where_clause.instance_variable_set(:@predicates, predicates)
26
+ where_clause
27
+ else
28
+ super
17
29
  end
18
30
  end
19
31
  end
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.5.11"
2
+ VERSION = "1.5.13"
3
3
  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: 1.5.11
4
+ version: 1.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-06-28 00:00:00.000000000 Z
13
+ date: 2016-06-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties