switchman 1.13.3 → 1.14.0

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: ec8bd036f45f143718da9a25f56578e9d79217ce053df66eb828eafe5f2edd15
4
- data.tar.gz: '0236808209e855742dc8caaf113176d6b6045db37c782c0e6eff69e8ae422370'
3
+ metadata.gz: 730c18de3f2e731bbbdce7ff8405691a0530510fa62ef552ae526728c92f1572
4
+ data.tar.gz: 8fbf3a6f789e76816e08af306404c8c5f04be944d4525289be82d00502c2df34
5
5
  SHA512:
6
- metadata.gz: a97ccc3066a172dc3261008b7ceca6e25dc8d352cbaec9ea1e3db383ce7a0cd4fe188f74522e503e16e40c60709338953671e1e4e99c90a46d13079546abea3a
7
- data.tar.gz: 62a28505e8c5fd3731de3d5ccf84b06d446b3adb9609f8cd5d14505b8cce9d9af608f44395ea6665ff6e8579facf22f7ceb6fbb3f5ec30a290dbdc8844efe75d
6
+ metadata.gz: bf7bafe9382647ce00b1323c168ce49f48d5d8d7db68718d75a9a05f6c4f02557e439aa941b9876273c962936891c757f89422727a50ff4ec4a5a045e40b6e23
7
+ data.tar.gz: c84822183e7448b8a9b2db7c9400d91429756e2b2f470fd1183a68e0d914b448cc1afb97ae3981fdf21a4a6f82c1eefb959d19fa801d4ac78120d8d31e300790
@@ -260,7 +260,7 @@ module Switchman
260
260
  # was started)
261
261
  # first, simplify the binary name by stripping directories,
262
262
  # then truncate arguments as necessary
263
- bin = File.basename(Process.argv0)
263
+ bin = File.basename($0) # Process.argv0 doesn't work on Ruby 2.5 (https://bugs.ruby-lang.org/issues/15887)
264
264
  max_length = 128 - bin.length - name.length - 3
265
265
  args = ARGV.join(" ")
266
266
  if max_length >= 0
@@ -76,15 +76,30 @@ module Switchman
76
76
 
77
77
  module Preloader
78
78
  module Association
79
- if ::Rails.version >= "5.2"
79
+ if ::Rails.version >= "5.2" and ::Rails.version < "6.0"
80
80
  def run(preloader)
81
- # TODO - can move associated_records_by_owner into this after 5.1 is gonzo
82
81
  associated_records_by_owner(preloader).each do |owner, records|
83
82
  associate_records_to_owner(owner, records)
84
83
  end
85
84
  end
86
85
  end
87
86
 
87
+ if ::Rails.version >= "6.0"
88
+ # Copypasta from Activerecord but with added global_id_for goodness.
89
+ def records_for(ids)
90
+ scope.where(association_key_name => ids).load do |record|
91
+ global_key = Shard.global_id_for(record[association_key_name], record.shard)
92
+ owner = owners_by_key[global_key.to_s].first
93
+ association = owner.association(reflection.name)
94
+ association.set_inverse_instance(record)
95
+ end
96
+ end
97
+
98
+ def records_by_owner
99
+ associated_records_by_owner
100
+ end
101
+ end
102
+
88
103
  def associated_records_by_owner(preloader = nil)
89
104
  owners_map = owners_by_key
90
105
 
@@ -121,7 +121,9 @@ module Switchman
121
121
  group_fields = group_attrs
122
122
  end
123
123
 
124
- group_aliases = group_fields.map { |field| column_alias_for(field) }
124
+ # .clone below corrects for what I consider a Rails bug. column_alias_for modifies the string in place.
125
+ # to_s is because Rails 5 returns a string but Rails 6 returns a symbol.
126
+ group_aliases = group_fields.map { |field| column_alias_for(field.clone).to_s }
125
127
  group_columns = group_aliases.zip(group_fields).map { |aliaz, field|
126
128
  [aliaz, type_for(field), column_name_for(field)]
127
129
  }
@@ -227,6 +227,10 @@ module Switchman
227
227
  connection.with_local_table_name { super }
228
228
  end
229
229
 
230
+ def arel_column(columns)
231
+ connection.with_local_table_name { super }
232
+ end
233
+
230
234
  # semi-private
231
235
  public
232
236
  def transpose_predicates(predicates,
@@ -40,8 +40,14 @@ module Switchman
40
40
  def database_servers
41
41
  unless @database_servers
42
42
  @database_servers = {}.with_indifferent_access
43
- ::ActiveRecord::Base.configurations.each do |(id, config)|
44
- @database_servers[id] = DatabaseServer.new(id, config)
43
+ if ::Rails.version >= '6.0'
44
+ ::ActiveRecord::Base.configurations.configurations.each do |config|
45
+ @database_servers[config.env_name] = DatabaseServer.new(config.env_name, config.config)
46
+ end
47
+ else
48
+ ::ActiveRecord::Base.configurations.each do |(id, config)|
49
+ @database_servers[id] = DatabaseServer.new(id, config)
50
+ end
45
51
  end
46
52
  end
47
53
  @database_servers
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.13.3"
2
+ VERSION = "1.14.0"
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.13.3
4
+ version: 1.14.0
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: 2019-05-14 00:00:00.000000000 Z
13
+ date: 2019-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '5.0'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '5.3'
24
+ version: '6.1'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,7 +31,7 @@ dependencies:
31
31
  version: '5.0'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '5.3'
34
+ version: '6.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: activerecord
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: '5.0'
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
- version: '5.3'
44
+ version: '6.1'
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,21 +51,21 @@ dependencies:
51
51
  version: '5.0'
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.3'
54
+ version: '6.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: shackles
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: 1.4.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
68
+ version: 1.4.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: open4
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -238,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
238
  requirements:
239
239
  - - ">="
240
240
  - !ruby/object:Gem::Version
241
- version: '2.3'
241
+ version: '2.4'
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  requirements:
244
244
  - - ">="