switchman 3.3.3 → 3.3.5

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: 786c667d13377d8e04408f506d0bdb01cf64143a89ba029c0fc373d840851c01
4
- data.tar.gz: 01a1e23d2622783d9cc93d36cbec0dbbfd1e4e71d264e7a5e92db9f5446475f2
3
+ metadata.gz: b02846fe7319e31d24a50618d5b2f7120109e09c4a4dc40125a25f7299207bf0
4
+ data.tar.gz: bd42f42242e7f0b8cc88ca76206625607ad00e33d58247ac6bd9d090f7c3722a
5
5
  SHA512:
6
- metadata.gz: 536073d8679b9b4bc5aa1facfea63ac6289caacca60177264321a75bae80c3795bb7941636cb27b1478ac64a6f0f4df9508a5f4ad6f401f200762050ba2e3a9e
7
- data.tar.gz: 64a835f1bf27b2a783f9e834004c43d2c8588b3df22468d5c795e9f6b273d70d1ae8b2645ffab7ff2b23cc8567a0af7d60c37b9136463f0e93378ff965ed0139
6
+ metadata.gz: 4109620cb05413f9ebfc56290e74e73d94682439a62cd1813b93ffb2b28aff2ec84aafb5bb888a283e418c8fcbe743b384bc09d3cd18f2d5008920e2707d491f
7
+ data.tar.gz: c5ce42651aed4080935281b4a131d56517bf84dc78c2dc38f0ce3ec6db62387b0848120392eb2187e8f86a2b61557c0a1ad34e1482cbed2f9b3f4cfbf90bfd22
@@ -3,6 +3,23 @@
3
3
  module Switchman
4
4
  module ActiveRecord
5
5
  module ConnectionPool
6
+ def get_schema_cache(connection)
7
+ self.schema_cache ||= SharedSchemaCache.get_schema_cache(connection)
8
+ self.schema_cache.connection = connection
9
+
10
+ self.schema_cache
11
+ end
12
+
13
+ # rubocop:disable Naming/AccessorMethodName override method
14
+ def set_schema_cache(cache)
15
+ schema_cache = get_schema_cache(cache.connection)
16
+
17
+ cache.instance_variables.each do |x|
18
+ schema_cache.instance_variable_set(x, cache.instance_variable_get(x))
19
+ end
20
+ end
21
+ # rubocop:enable Naming/AccessorMethodName override method
22
+
6
23
  def default_schema
7
24
  connection unless @schemas
8
25
  # default shard will not switch databases immediately, so it won't be set yet
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Switchman
4
+ class SharedSchemaCache
5
+ def self.get_schema_cache(connection)
6
+ @schema_cache ||= ::ActiveRecord::ConnectionAdapters::SchemaCache.new(connection)
7
+ @schema_cache.connection = connection
8
+ @schema_cache
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = '3.3.3'
4
+ VERSION = '3.3.5'
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: 3.3.3
4
+ version: 3.3.5
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: 2023-03-11 00:00:00.000000000 Z
13
+ date: 2023-03-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -290,6 +290,7 @@ files:
290
290
  - lib/switchman/rails.rb
291
291
  - lib/switchman/shard.rb
292
292
  - lib/switchman/sharded_instrumenter.rb
293
+ - lib/switchman/shared_schema_cache.rb
293
294
  - lib/switchman/standard_error.rb
294
295
  - lib/switchman/test_helper.rb
295
296
  - lib/switchman/unsharded_record.rb