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 +4 -4
- data/app/models/switchman/shard_internal.rb +1 -1
- data/lib/switchman/active_record/association.rb +17 -2
- data/lib/switchman/active_record/calculations.rb +3 -1
- data/lib/switchman/active_record/query_methods.rb +4 -0
- data/lib/switchman/database_server.rb +8 -2
- data/lib/switchman/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 730c18de3f2e731bbbdce7ff8405691a0530510fa62ef552ae526728c92f1572
|
4
|
+
data.tar.gz: 8fbf3a6f789e76816e08af306404c8c5f04be944d4525289be82d00502c2df34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
}
|
@@ -40,8 +40,14 @@ module Switchman
|
|
40
40
|
def database_servers
|
41
41
|
unless @database_servers
|
42
42
|
@database_servers = {}.with_indifferent_access
|
43
|
-
::
|
44
|
-
|
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
|
data/lib/switchman/version.rb
CHANGED
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.
|
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-
|
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: '
|
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: '
|
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: '
|
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: '
|
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:
|
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:
|
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.
|
241
|
+
version: '2.4'
|
242
242
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
243
|
requirements:
|
244
244
|
- - ">="
|