active_record_shards 3.20.0 → 3.21.0

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: faa823b7357f66f7de85bb3ab50b6df99beb0c2505bcbbeafac9cc1aa4581d7e
4
- data.tar.gz: 688c6ed703809a88ee86134d43021730495bcaaa8ca2132c81a0926edc2d1eca
3
+ metadata.gz: aadf0c3e7681201dfc6b2f9ff1c9a33164d7e9b17394052e09601f807926c73a
4
+ data.tar.gz: 3e1eaac98dbcdeb6133787447fdd4a7c56aa4056013e9b01aa2082f00a6bc733
5
5
  SHA512:
6
- metadata.gz: 8e9babc77b5dffe78007005f7abec607a9e5597aafa3676082c501da68c9cce9748714db5068bdc6b7573edef1ed8ad608893820c5396fbc450fa59b5c34f9f2
7
- data.tar.gz: 72dcbaa612143fe7a3235f23982b83b4fddb86a7c39814dec128d7fc6f4a141b368de82392e2f515424055b148d11181fc3fd27e608f174879735c30d1d13ce4
6
+ metadata.gz: eecd43504f6dcb074c97128d96a2b5bbeeea08bc92e6c005bc3b8d3952670ea7a201856709b50c0ad5e4d91db1eb9aac9bba02762a424eaa3a23bb44c00fbdbd
7
+ data.tar.gz: 1f91bc255828d9bae15bf5267a5a836049e12eef663751dbad63de1f35e84cea566f071f290db96f84accc4bb20c2d52c82cbedbe79a6bc637769cae7aeafa75
data/README.md CHANGED
@@ -148,12 +148,16 @@ ActiveRecord::Base.on_replica do
148
148
  end
149
149
  ```
150
150
 
151
- This will perform the query on the replica, and mark the returned instances as read only. There is also a shortcut for this:
151
+ This will perform the query on the replica, and mark the returned instances as read-only. There is also a shortcut for this:
152
152
 
153
153
  ```ruby
154
154
  Account.on_replica.find_by_big_expensive_query
155
155
  ```
156
156
 
157
+ If you do not want instances returned from replicas to be marked as read-only, this can be disabled globally:
158
+
159
+ `ActiveRecordShards.disable_replica_readonly_records = true`
160
+
157
161
  ## Debugging
158
162
 
159
163
  Show if a query went to primary or replica in the logs:
@@ -125,7 +125,7 @@ module ActiveRecordShards
125
125
 
126
126
  # we avoid_readonly_scope to prevent some stack overflow problems, like when
127
127
  # .columns calls .with_scope which calls .columns and onward, endlessly.
128
- if self == ActiveRecord::Base || !switch_to_replica || construct_ro_scope == false
128
+ if self == ActiveRecord::Base || !switch_to_replica || construct_ro_scope == false || ActiveRecordShards.disable_replica_readonly_records == true
129
129
  yield
130
130
  else
131
131
  readonly.scoping(&block)
@@ -12,6 +12,10 @@ require 'active_record_shards/default_replica_patches'
12
12
  require 'active_record_shards/schema_dumper_extension'
13
13
 
14
14
  module ActiveRecordShards
15
+ class << self
16
+ attr_accessor :disable_replica_readonly_records
17
+ end
18
+
15
19
  def self.app_env
16
20
  env = Rails.env if defined?(Rails.env)
17
21
  env ||= RAILS_ENV if Object.const_defined?(:RAILS_ENV)
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: 3.20.0
4
+ version: 3.21.0
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: 2022-04-23 00:00:00.000000000 Z
16
+ date: 2022-07-05 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.3.1
236
+ rubygems_version: 3.1.6
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: Simple database switching for ActiveRecord.