active_record_shards 5.4.0 → 5.4.1

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: fbcc8e394ddfa2267939c38fe1612c0c410f549ca6d45fc52469ccd564771fcd
4
- data.tar.gz: 2e87a9063cfe63fe47d58d5bf8e7b84dc88755cb39f81b88db3954a8c5a65868
3
+ metadata.gz: 0dad44339b071fbea35fbf5298c8a1ded5f78ecabb97a4e48da974c1191b94cd
4
+ data.tar.gz: ddfe5d8a76e1007ea68a85d7cd0bad6b8c0334752136a8a72574d2d776fb1de5
5
5
  SHA512:
6
- metadata.gz: 5eec3bce25a92f77f583a258efd2f054efce9f58b4e49c72be84e3cf352da02d7a8ab984ba349014dbe0f28b45cf347d2935512e97c88c349a9507b6338ce9f1
7
- data.tar.gz: 4d9778bd1883639073fe77cf36a5de42de5d14ac1acd45303e80f4c37998a3c5ec00445578df9367a298c8d2c07111b2dd41e7cd6545b4e3f05f3b95d1eb2386
6
+ metadata.gz: 751f5301b1a0fac6834ed5571b992e71ae0e6e18c4ac9cd94acd64c56650fe08961d50350bed19b0db23d9bdac98d18b8ba7cf46f958278dcc882418b3408257
7
+ data.tar.gz: 4866f71bd64c603cf997638607fd93100c264c0ac4b910d7ee5e20237f53cd06756093f2cf27712453d536e52fc9898b688466fd7c080d893db5494480fcf3e8
@@ -7,6 +7,10 @@ module ActiveRecordShards
7
7
  class LegacyConnectionHandlingError < StandardError; end
8
8
  class IsolationLevelError < StandardError; end
9
9
 
10
+ Thread.attr_accessor :_active_record_shards_disallow_replica_by_thread,
11
+ :_active_record_shards_in_migration,
12
+ :_active_record_shards_shard_selection
13
+
10
14
  case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
11
15
  when '6.1', '7.0'
12
16
  SHARD_NAMES_CONFIG_KEY = :shard_names
@@ -119,11 +123,11 @@ module ActiveRecordShards
119
123
  end
120
124
 
121
125
  def disallow_replica=(value)
122
- Thread.current[:__active_record_shards__disallow_replica_by_thread] = value
126
+ Thread.current._active_record_shards_disallow_replica_by_thread = value
123
127
  end
124
128
 
125
129
  def disallow_replica
126
- Thread.current[:__active_record_shards__disallow_replica_by_thread] ||= 0
130
+ Thread.current._active_record_shards_disallow_replica_by_thread ||= 0
127
131
  end
128
132
 
129
133
  def supports_sharding?
@@ -135,8 +139,7 @@ module ActiveRecordShards
135
139
  end
136
140
 
137
141
  def current_shard_selection
138
- cs = Thread.current.thread_variable_get(:shard_selection) || ShardSelection.new
139
- Thread.current.thread_variable_set(:shard_selection, cs)
142
+ Thread.current._active_record_shards_shard_selection ||= ShardSelection.new
140
143
  end
141
144
 
142
145
  def current_shard_id
@@ -69,7 +69,7 @@ module ActiveRecordShards
69
69
  end
70
70
 
71
71
  def on_replica_unless_tx(&block)
72
- return yield if Thread.current[:_active_record_shards_in_migration]
72
+ return yield if Thread.current._active_record_shards_in_migration
73
73
  return yield if _in_transaction?
74
74
 
75
75
  if on_replica_by_default?
@@ -84,7 +84,7 @@ module ActiveRecordShards
84
84
  end
85
85
 
86
86
  def force_on_replica(&block)
87
- return yield if Thread.current[:_active_record_shards_in_migration]
87
+ return yield if Thread.current._active_record_shards_in_migration
88
88
 
89
89
  on_cx_switch_block(:replica, construct_ro_scope: false, force: true, &block)
90
90
  end
@@ -105,7 +105,7 @@ module ActiveRecordShards
105
105
 
106
106
  module Rails52RelationPatches
107
107
  def connection
108
- return super if Thread.current[:_active_record_shards_in_migration]
108
+ return super if Thread.current._active_record_shards_in_migration
109
109
  return super if _in_transaction?
110
110
 
111
111
  if @klass.on_replica_by_default?
@@ -197,7 +197,7 @@ module ActiveRecordShards
197
197
 
198
198
  module TypeCasterConnectionConnectionPatch
199
199
  def connection
200
- return super if Thread.current[:_active_record_shards_in_migration]
200
+ return super if Thread.current._active_record_shards_in_migration
201
201
  return super if ActiveRecord::Base._in_transaction?
202
202
 
203
203
  if @klass.on_replica_by_default?
@@ -210,11 +210,11 @@ module ActiveRecordShards
210
210
 
211
211
  module SchemaDefinePatch
212
212
  def define(info, &block)
213
- old_val = Thread.current[:_active_record_shards_in_migration]
214
- Thread.current[:_active_record_shards_in_migration] = true
213
+ old_val = Thread.current._active_record_shards_in_migration
214
+ Thread.current._active_record_shards_in_migration = true
215
215
  super
216
216
  ensure
217
- Thread.current[:_active_record_shards_in_migration] = old_val
217
+ Thread.current._active_record_shards_in_migration = old_val
218
218
  end
219
219
  end
220
220
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Quorning
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-08-03 00:00:00.000000000 Z
16
+ date: 2023-08-04 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord