switchman 1.3.14 → 1.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010808.501083:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010554.0700731:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1451933188.736288:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1451933234.6297421:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010783.857971:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010659.830157:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETisI" name;TI" shard1;TI"database_server_id;T0I" default;TF:@created_atf1452010783.491301:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�I" name;TI" shard1;TI"database_server_id;T0I" default;TF:@created_atf1452010809.686368:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETitI" name;TI" shard2;TI"database_server_id;TI"1;TI" default;TF:@created_atf1452010783.455478:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value{ I"id:ETi�I" name;TI" shard2;TI"database_server_id;TI"1;TI" default;TF:@created_atf1452010809.6884391:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010553.969727:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1451933188.15386:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010659.781048:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1451933233.980086:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010783.468508:@expires_in0
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry: @value:nil:@created_atf1452010808.2569878:@expires_in0
@@ -119,12 +119,12 @@ module Switchman
119
119
  relation = @user1.appendages.where(:id => a1).shard(@shard1)
120
120
  expect(relation.shard_value).to eq @shard1
121
121
  expect(relation.shard_source_value).to eq :explicit
122
- expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq a1.local_id
122
+ expect(where_value(relation.where_values.detect{|v| v.left.name == "id"}.right)).to eq a1.local_id
123
123
 
124
124
  relation = @user1.appendages.where(:id => a1).shard(@shard2)
125
125
  expect(relation.shard_value).to eq @shard2
126
126
  expect(relation.shard_source_value).to eq :explicit
127
- expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq a1.global_id
127
+ expect(where_value(relation.where_values.detect{|v| v.left.name == "id"}.right)).to eq a1.global_id
128
128
  end
129
129
 
130
130
  it "should transpose predicates correctly" do
@@ -133,11 +133,11 @@ module Switchman
133
133
 
134
134
  relation = @user1.appendages.where(:id => a2)
135
135
  expect(relation.shard_value).to eq @user1
136
- expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq a2.global_id
136
+ expect(where_value(relation.where_values.detect{|v| v.left.name == "id"}.right)).to eq a2.global_id
137
137
 
138
138
  relation = @user1.appendages.where(:id => [a1, a2])
139
139
  expect(relation.shard_value).to eq @user1
140
- expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq [a1.local_id, a2.global_id]
140
+ expect(where_value(relation.where_values.detect{|v| v.left.name == "id"}.right)).to eq [a1.local_id, a2.global_id]
141
141
  end
142
142
 
143
143
  it "should properly set up a cross-shard-category query" do
@@ -58,46 +58,46 @@ module Switchman
58
58
  relation = User.where(:id => @user1).shard(@shard1)
59
59
  expect(relation.shard_value).to eq @shard1
60
60
  expect(relation.shard_source_value).to eq :explicit
61
- expect(relation.where_values.first.right).to eq @user1.global_id
61
+ expect(where_value(relation.where_values.first.right)).to eq @user1.global_id
62
62
  end
63
63
 
64
64
  it "should infer the shard from a single argument" do
65
65
  relation = User.where(:id => @user2)
66
66
  # execute on @shard1, with id local to that shard
67
67
  expect(relation.shard_value).to eq @shard1
68
- expect(relation.where_values.first.right).to eq @user2.local_id
68
+ expect(where_value(relation.where_values.first.right)).to eq @user2.local_id
69
69
  end
70
70
 
71
71
  it "should infer the shard from multiple arguments" do
72
72
  relation = User.where(:id => [@user2, @user2])
73
73
  # execute on @shard1, with id local to that shard
74
74
  expect(relation.shard_value).to eq @shard1
75
- expect(relation.where_values.first.right).to eq [@user2.local_id, @user2.local_id]
75
+ expect(where_value(relation.where_values.first.right)).to eq [@user2.local_id, @user2.local_id]
76
76
  end
77
77
 
78
78
  it "should infer the correct shard from an array of 1" do
79
79
  relation = User.where(:id => [@user2])
80
80
  # execute on @shard1, with id local to that shard
81
81
  expect(relation.shard_value).to eq @shard1
82
- expect(Array(relation.where_values.first.right)).to eq [@user2.local_id]
82
+ expect(where_value(Array(relation.where_values.first.right))).to eq [@user2.local_id]
83
83
  end
84
84
 
85
85
  it "should do nothing when it's an array of 0" do
86
86
  relation = User.where(:id => [])
87
87
  # execute on @shard1, with id local to that shard
88
88
  expect(relation.shard_value).to eq Shard.default
89
- expect(relation.where_values.first.right).to eq []
89
+ expect(where_value(relation.where_values.first.right)).to eq []
90
90
  end
91
91
 
92
92
  it "should order the shards preferring the shard it already had as primary" do
93
93
  relation = User.where(:id => [@user1, @user2])
94
94
  expect(relation.shard_value).to eq [Shard.default, @shard1]
95
- expect(relation.where_values.first.right).to eq [@user1.local_id, @user2.global_id]
95
+ expect(where_value(relation.where_values.first.right)).to eq [@user1.local_id, @user2.global_id]
96
96
 
97
97
  @shard1.activate do
98
98
  relation = User.where(:id => [@user1, @user2])
99
99
  expect(relation.shard_value).to eq [@shard1, Shard.default]
100
- expect(relation.where_values.first.right).to eq [@user1.global_id, @user2.local_id]
100
+ expect(where_value(relation.where_values.first.right)).to eq [@user1.global_id, @user2.local_id]
101
101
  end
102
102
  end
103
103
  end
@@ -107,34 +107,34 @@ module Switchman
107
107
  relation = Appendage.where(:user_id => @user1)
108
108
  expect(relation.shard_value).to eq Shard.default
109
109
  expect(relation.shard_source_value).to eq :implicit
110
- expect(relation.where_values.first.right).to eq @user1.local_id
110
+ expect(where_value(relation.where_values.first.right)).to eq @user1.local_id
111
111
 
112
112
  relation = relation.shard(@shard1)
113
113
  expect(relation.shard_value).to eq @shard1
114
114
  expect(relation.shard_source_value).to eq :explicit
115
- expect(relation.where_values.first.right).to eq @user1.global_id
115
+ expect(where_value(relation.where_values.first.right)).to eq @user1.global_id
116
116
  end
117
117
 
118
118
  it "should translate ids based on current shard" do
119
119
  relation = Appendage.where(:user_id => [@user1, @user2])
120
- expect(relation.where_values.first.right).to eq [@user1.local_id, @user2.global_id]
120
+ expect(where_value(relation.where_values.first.right)).to eq [@user1.local_id, @user2.global_id]
121
121
 
122
122
  @shard1.activate do
123
123
  relation = Appendage.where(:user_id => [@user1, @user2])
124
- expect(relation.where_values.first.right).to eq [@user1.global_id, @user2.local_id]
124
+ expect(where_value(relation.where_values.first.right)).to eq [@user1.global_id, @user2.local_id]
125
125
  end
126
126
  end
127
127
 
128
128
  it "should translate ids in joins" do
129
129
  relation = User.joins(:appendage).where(appendages: { user_id: [@user1, @user2]})
130
- expect(relation.where_values.first.right).to eq [@user1.local_id, @user2.global_id]
130
+ expect(where_value(relation.where_values.first.right)).to eq [@user1.local_id, @user2.global_id]
131
131
  end
132
132
 
133
133
  it "should translate ids according to the current shard of the foreign type" do
134
134
  @shard1.activate(:mirror_universe) do
135
135
  mirror_user = MirrorUser.create!
136
136
  relation = User.where(mirror_user_id: mirror_user)
137
- expect(relation.where_values.first.right).to eq mirror_user.global_id
137
+ expect(where_value(relation.where_values.first.right)).to eq mirror_user.global_id
138
138
  end
139
139
  end
140
140
  end
data/spec/spec_helper.rb CHANGED
@@ -32,3 +32,18 @@ RSpec.configure do |config|
32
32
  # --seed 1234
33
33
  config.order = "random"
34
34
  end
35
+
36
+ def where_value(value)
37
+ if ::Rails.version >= "4.2"
38
+ case value
39
+ when ::Arel::Nodes::Casted
40
+ value.val
41
+ when Array
42
+ value.map{|v| where_value(v)}
43
+ else
44
+ value
45
+ end
46
+ else
47
+ value
48
+ end
49
+ 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.3.14
4
+ version: 1.3.15
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: 2015-12-29 00:00:00.000000000 Z
13
+ date: 2016-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -365,7 +365,13 @@ files:
365
365
  - spec/dummy/db/shard_43.sqlite3
366
366
  - spec/dummy/db/shard_4308.sqlite3
367
367
  - spec/dummy/db/shard_4346.sqlite3
368
+ - spec/dummy/db/shard_4365.sqlite3
369
+ - spec/dummy/db/shard_4406.sqlite3
370
+ - spec/dummy/db/shard_4420.sqlite3
371
+ - spec/dummy/db/shard_4461.sqlite3
368
372
  - spec/dummy/db/shard_448.sqlite3
373
+ - spec/dummy/db/shard_4486.sqlite3
374
+ - spec/dummy/db/shard_4498.sqlite3
369
375
  - spec/dummy/db/shard_471.sqlite3
370
376
  - spec/dummy/db/shard_492.sqlite3
371
377
  - spec/dummy/db/shard_519.sqlite3
@@ -570,6 +576,7 @@ files:
570
576
  - spec/dummy/tmp/cache/37C/610/shard%2F2460
571
577
  - spec/dummy/tmp/cache/37C/610/shard%2F2703
572
578
  - spec/dummy/tmp/cache/37C/630/shard%2F1911
579
+ - spec/dummy/tmp/cache/37C/640/shard%2F4512
573
580
  - spec/dummy/tmp/cache/37D/570/shard%2F1066
574
581
  - spec/dummy/tmp/cache/37D/570/shard%2F1147
575
582
  - spec/dummy/tmp/cache/37D/590/shard%2F1084
@@ -674,11 +681,15 @@ files:
674
681
  - spec/dummy/tmp/cache/381/680/shard%2F3617
675
682
  - spec/dummy/tmp/cache/381/690/shard%2F2654
676
683
  - spec/dummy/tmp/cache/381/690/shard%2F3626
684
+ - spec/dummy/tmp/cache/381/690/shard%2F4436
677
685
  - spec/dummy/tmp/cache/381/6A0/shard%2F1691
678
686
  - spec/dummy/tmp/cache/381/6B0/shard%2F3725
679
687
  - spec/dummy/tmp/cache/381/6C0/shard%2F3653
688
+ - spec/dummy/tmp/cache/381/6C0/shard%2F4382
689
+ - spec/dummy/tmp/cache/381/6D0/shard%2F4391
680
690
  - spec/dummy/tmp/cache/381/6E0/shard%2F3671
681
691
  - spec/dummy/tmp/cache/381/6F0/shard%2F3680
692
+ - spec/dummy/tmp/cache/381/6F0/shard%2F4490
682
693
  - spec/dummy/tmp/cache/382/650/shard%2F1395
683
694
  - spec/dummy/tmp/cache/382/650/shard%2F2529
684
695
  - spec/dummy/tmp/cache/382/660/shard%2F3186
@@ -688,6 +699,7 @@ files:
688
699
  - spec/dummy/tmp/cache/382/690/shard%2F4185
689
700
  - spec/dummy/tmp/cache/382/6A0/shard%2F2493
690
701
  - spec/dummy/tmp/cache/382/6A0/shard%2F4194
702
+ - spec/dummy/tmp/cache/382/6B0/shard%2F4446
691
703
  - spec/dummy/tmp/cache/382/6C0/shard%2F2592
692
704
  - spec/dummy/tmp/cache/382/6F0/shard%2F2943
693
705
  - spec/dummy/tmp/cache/382/700/shard%2F1980
@@ -744,14 +756,18 @@ files:
744
756
  - spec/dummy/tmp/cache/385/6D0/shard%2F1929
745
757
  - spec/dummy/tmp/cache/385/6D0/shard%2F2577
746
758
  - spec/dummy/tmp/cache/385/6E0/shard%2F3558
759
+ - spec/dummy/tmp/cache/385/700/shard%2F4467
747
760
  - spec/dummy/tmp/cache/385/710/shard%2F3909
748
761
  - spec/dummy/tmp/cache/385/720/shard%2F2784
762
+ - spec/dummy/tmp/cache/385/730/shard%2F4494
749
763
  - spec/dummy/tmp/cache/385/750/shard%2F3864
750
764
  - spec/dummy/tmp/cache/385/760/shard%2F3792
751
765
  - spec/dummy/tmp/cache/386/6B0/shard%2F3199
752
766
  - spec/dummy/tmp/cache/386/6F0/shard%2F3397
753
767
  - spec/dummy/tmp/cache/386/700/shard%2F1786
754
768
  - spec/dummy/tmp/cache/386/710/shard%2F3496
769
+ - spec/dummy/tmp/cache/386/710/shard%2F4468
770
+ - spec/dummy/tmp/cache/386/740/shard%2F4495
755
771
  - spec/dummy/tmp/cache/386/760/shard%2F2974
756
772
  - spec/dummy/tmp/cache/387/6D0/shard%2F2399
757
773
  - spec/dummy/tmp/cache/387/6E0/shard%2F3299
@@ -907,7 +923,10 @@ files:
907
923
  - spec/dummy/tmp/cache/3AE/080/shard%2F12551
908
924
  - spec/dummy/tmp/cache/3AE/080/shard%2F14252
909
925
  - spec/dummy/tmp/cache/3AE/080/shard%2F14333
926
+ - spec/dummy/tmp/cache/3AE/080/shard%2F14414
910
927
  - spec/dummy/tmp/cache/3AE/090/shard%2F13451
928
+ - spec/dummy/tmp/cache/3AE/0B0/shard%2F14360
929
+ - spec/dummy/tmp/cache/3AE/0B0/shard%2F14441
911
930
  - spec/dummy/tmp/cache/3AE/0F0/shard%2F13910
912
931
  - spec/dummy/tmp/cache/3AE/F70/shard%2F10049
913
932
  - spec/dummy/tmp/cache/3AE/FA0/shard%2F10319
@@ -1078,6 +1097,9 @@ files:
1078
1097
  - spec/dummy/tmp/cache/3B7/130/shard%2F14198
1079
1098
  - spec/dummy/tmp/cache/3B7/130/shard%2F14279
1080
1099
  - spec/dummy/tmp/cache/3B7/150/shard%2F12677
1100
+ - spec/dummy/tmp/cache/3B7/160/shard%2F14387
1101
+ - spec/dummy/tmp/cache/3B7/160/shard%2F14468
1102
+ - spec/dummy/tmp/cache/3B7/190/shard%2F14495
1081
1103
  - spec/dummy/tmp/cache/3B8/120/shard%2F10698
1082
1104
  - spec/dummy/tmp/cache/3B8/130/shard%2F10869
1083
1105
  - spec/dummy/tmp/cache/3B8/160/shard%2F10896
@@ -1365,7 +1387,13 @@ test_files:
1365
1387
  - spec/dummy/db/shard_43.sqlite3
1366
1388
  - spec/dummy/db/shard_4308.sqlite3
1367
1389
  - spec/dummy/db/shard_4346.sqlite3
1390
+ - spec/dummy/db/shard_4365.sqlite3
1391
+ - spec/dummy/db/shard_4406.sqlite3
1392
+ - spec/dummy/db/shard_4420.sqlite3
1393
+ - spec/dummy/db/shard_4461.sqlite3
1368
1394
  - spec/dummy/db/shard_448.sqlite3
1395
+ - spec/dummy/db/shard_4486.sqlite3
1396
+ - spec/dummy/db/shard_4498.sqlite3
1369
1397
  - spec/dummy/db/shard_471.sqlite3
1370
1398
  - spec/dummy/db/shard_492.sqlite3
1371
1399
  - spec/dummy/db/shard_519.sqlite3
@@ -1571,6 +1599,7 @@ test_files:
1571
1599
  - spec/dummy/tmp/cache/37C/610/shard%2F2460
1572
1600
  - spec/dummy/tmp/cache/37C/610/shard%2F2703
1573
1601
  - spec/dummy/tmp/cache/37C/630/shard%2F1911
1602
+ - spec/dummy/tmp/cache/37C/640/shard%2F4512
1574
1603
  - spec/dummy/tmp/cache/37D/570/shard%2F1066
1575
1604
  - spec/dummy/tmp/cache/37D/570/shard%2F1147
1576
1605
  - spec/dummy/tmp/cache/37D/590/shard%2F1084
@@ -1675,11 +1704,15 @@ test_files:
1675
1704
  - spec/dummy/tmp/cache/381/680/shard%2F3617
1676
1705
  - spec/dummy/tmp/cache/381/690/shard%2F2654
1677
1706
  - spec/dummy/tmp/cache/381/690/shard%2F3626
1707
+ - spec/dummy/tmp/cache/381/690/shard%2F4436
1678
1708
  - spec/dummy/tmp/cache/381/6A0/shard%2F1691
1679
1709
  - spec/dummy/tmp/cache/381/6B0/shard%2F3725
1680
1710
  - spec/dummy/tmp/cache/381/6C0/shard%2F3653
1711
+ - spec/dummy/tmp/cache/381/6C0/shard%2F4382
1712
+ - spec/dummy/tmp/cache/381/6D0/shard%2F4391
1681
1713
  - spec/dummy/tmp/cache/381/6E0/shard%2F3671
1682
1714
  - spec/dummy/tmp/cache/381/6F0/shard%2F3680
1715
+ - spec/dummy/tmp/cache/381/6F0/shard%2F4490
1683
1716
  - spec/dummy/tmp/cache/382/650/shard%2F1395
1684
1717
  - spec/dummy/tmp/cache/382/650/shard%2F2529
1685
1718
  - spec/dummy/tmp/cache/382/660/shard%2F3186
@@ -1689,6 +1722,7 @@ test_files:
1689
1722
  - spec/dummy/tmp/cache/382/690/shard%2F4185
1690
1723
  - spec/dummy/tmp/cache/382/6A0/shard%2F2493
1691
1724
  - spec/dummy/tmp/cache/382/6A0/shard%2F4194
1725
+ - spec/dummy/tmp/cache/382/6B0/shard%2F4446
1692
1726
  - spec/dummy/tmp/cache/382/6C0/shard%2F2592
1693
1727
  - spec/dummy/tmp/cache/382/6F0/shard%2F2943
1694
1728
  - spec/dummy/tmp/cache/382/700/shard%2F1980
@@ -1745,14 +1779,18 @@ test_files:
1745
1779
  - spec/dummy/tmp/cache/385/6D0/shard%2F1929
1746
1780
  - spec/dummy/tmp/cache/385/6D0/shard%2F2577
1747
1781
  - spec/dummy/tmp/cache/385/6E0/shard%2F3558
1782
+ - spec/dummy/tmp/cache/385/700/shard%2F4467
1748
1783
  - spec/dummy/tmp/cache/385/710/shard%2F3909
1749
1784
  - spec/dummy/tmp/cache/385/720/shard%2F2784
1785
+ - spec/dummy/tmp/cache/385/730/shard%2F4494
1750
1786
  - spec/dummy/tmp/cache/385/750/shard%2F3864
1751
1787
  - spec/dummy/tmp/cache/385/760/shard%2F3792
1752
1788
  - spec/dummy/tmp/cache/386/6B0/shard%2F3199
1753
1789
  - spec/dummy/tmp/cache/386/6F0/shard%2F3397
1754
1790
  - spec/dummy/tmp/cache/386/700/shard%2F1786
1755
1791
  - spec/dummy/tmp/cache/386/710/shard%2F3496
1792
+ - spec/dummy/tmp/cache/386/710/shard%2F4468
1793
+ - spec/dummy/tmp/cache/386/740/shard%2F4495
1756
1794
  - spec/dummy/tmp/cache/386/760/shard%2F2974
1757
1795
  - spec/dummy/tmp/cache/387/6D0/shard%2F2399
1758
1796
  - spec/dummy/tmp/cache/387/6E0/shard%2F3299
@@ -1908,7 +1946,10 @@ test_files:
1908
1946
  - spec/dummy/tmp/cache/3AE/080/shard%2F12551
1909
1947
  - spec/dummy/tmp/cache/3AE/080/shard%2F14252
1910
1948
  - spec/dummy/tmp/cache/3AE/080/shard%2F14333
1949
+ - spec/dummy/tmp/cache/3AE/080/shard%2F14414
1911
1950
  - spec/dummy/tmp/cache/3AE/090/shard%2F13451
1951
+ - spec/dummy/tmp/cache/3AE/0B0/shard%2F14360
1952
+ - spec/dummy/tmp/cache/3AE/0B0/shard%2F14441
1912
1953
  - spec/dummy/tmp/cache/3AE/0F0/shard%2F13910
1913
1954
  - spec/dummy/tmp/cache/3AE/F70/shard%2F10049
1914
1955
  - spec/dummy/tmp/cache/3AE/FA0/shard%2F10319
@@ -2079,6 +2120,9 @@ test_files:
2079
2120
  - spec/dummy/tmp/cache/3B7/130/shard%2F14198
2080
2121
  - spec/dummy/tmp/cache/3B7/130/shard%2F14279
2081
2122
  - spec/dummy/tmp/cache/3B7/150/shard%2F12677
2123
+ - spec/dummy/tmp/cache/3B7/160/shard%2F14387
2124
+ - spec/dummy/tmp/cache/3B7/160/shard%2F14468
2125
+ - spec/dummy/tmp/cache/3B7/190/shard%2F14495
2082
2126
  - spec/dummy/tmp/cache/3B8/120/shard%2F10698
2083
2127
  - spec/dummy/tmp/cache/3B8/130/shard%2F10869
2084
2128
  - spec/dummy/tmp/cache/3B8/160/shard%2F10896