switchman 4.3.8 → 4.3.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06afc2db76ce24db251cf0485b461a73b673f3b4dbbaad3a5a627970636529f8
4
- data.tar.gz: db6536cdafbbf26452df0ca7de368b5bb8f7432e5108368350388c0ea1ce3122
3
+ metadata.gz: 4d54cb405479d21db976021502058d0a19ff90c7c7defb474159353957149cd8
4
+ data.tar.gz: a4a42a4b2f47f95282db95a2e385212161754bbb404f972059c3b69f8fa786d0
5
5
  SHA512:
6
- metadata.gz: 20b3089547fd6eb276b080d8abb701ea11e260aeceb36c712a899f42182df71dd91e7d3d2d70a2f49a552cd3382ad563dcf64a6755a23912d16e50c89b552296
7
- data.tar.gz: 6b015407234bfc385c129e4bee79c202fee8fceb4a10393cb4e096c86dcbd560d8ff19181ee2deaaa0f98ed48544660aa677751813c953491f46a9a9c86dcece
6
+ metadata.gz: d6d48cdef1bde0c6fa498829f112ed4196c66e82c424c9f2a3e7fadf1043617394c343de809a9e80af6ddbc9d098b9e08d0b6b41260a43d77cb62574494277d0
7
+ data.tar.gz: a0ce1835343dabeb7829023b3b673451a9489bbc81211aaf2128c885d80525d2dc0c8b4810cb52d6022ddecf82c02415e1632f3a79e5255cc67e28327d0c34cc
@@ -95,6 +95,8 @@ module Switchman
95
95
  end
96
96
 
97
97
  ::ActiveRecord::ConnectionAdapters::TableDefinition.prepend(ActiveRecord::TableDefinition)
98
+
99
+ ::ActiveRecord::TestFixtures.prepend(ActiveRecord::TestFixtures) # rubocop:disable Rails/ActiveSupportOnLoad
98
100
  end
99
101
 
100
102
  ::ActiveSupport.on_load(:active_record_postgresqladapter) do
@@ -108,7 +110,6 @@ module Switchman
108
110
  end
109
111
  end
110
112
 
111
- ::ActiveSupport.on_load(:active_record_fixtures) { prepend ActiveRecord::TestFixtures }
112
113
  # Ensure that ActiveRecord::Base is always loaded before any app-level
113
114
  # initializers can go try to load Switchman::Shard or we get a loop
114
115
  ::ActiveRecord::Base
@@ -76,11 +76,7 @@ module Switchman
76
76
  @default ||= default
77
77
 
78
78
  # Now find the actual record, if it exists
79
- @default = begin
80
- find_cached("default_shard") { Shard.find_by(default: true) } || default
81
- rescue
82
- default
83
- end
79
+ @default = find_default_shard(default)
84
80
 
85
81
  # make sure this is not erroneously cached
86
82
  if @default.database_server.instance_variable_defined?(:@primary_shard)
@@ -445,6 +441,21 @@ module Switchman
445
441
 
446
442
  private
447
443
 
444
+ def find_default_shard(fallback)
445
+ return fallback unless Switchman.cache
446
+
447
+ find_cached("default_shard") { Shard.find_by(default: true) } || fallback
448
+ rescue ::ActiveRecord::NoDatabaseError,
449
+ ::ActiveRecord::ConnectionNotEstablished,
450
+ ::ActiveRecord::ConnectionFailed,
451
+ ::PG::ConnectionBad
452
+ fallback
453
+ rescue ::ActiveRecord::StatementInvalid => e
454
+ raise unless e.cause.is_a?(::PG::UndefinedTable)
455
+
456
+ fallback
457
+ end
458
+
448
459
  def add_sharded_model(klass)
449
460
  @sharded_models = (sharded_models + [klass]).freeze
450
461
  configure_connects_to
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "4.3.8"
4
+ VERSION = "4.3.9"
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: 4.3.8
4
+ version: 4.3.9
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: 2026-09-14 00:00:00.000000000 Z
13
+ date: 2026-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord