frozen_record 0.25.0 → 0.25.1

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: d2be87eaecead5b4f1d4c5e941d48fcd9be163c56f2c9b988ec4d6ff7ea84757
4
- data.tar.gz: 0a4a51c609251f3a46ba49e16f85b1d27ce5e52581fb70bd605c8585b1f62fa8
3
+ metadata.gz: 2c4f3cb4248d83050752933b1a2c48d0bf0914a73e695932650a03cae9feffa0
4
+ data.tar.gz: fb8517287957255269ffec7ab7bac5740c6d7e45b4f1c3c0b321ce4fc5badf4f
5
5
  SHA512:
6
- metadata.gz: 4326747e566bdb03b700dd5bb8164b550f8d339991754cebeb2a5414f8858a4bb19c074ac2231d4e978be881ed0ff87611c107c69bbc2a21ba498b7d3eb563eb
7
- data.tar.gz: f73715f137336bada8a8aad2a3be9d6b4cf87f4de9dae6c2b77463201f7a3e510ae6c7491d9957db9c7d2b6df8280576e7e896eb8bf28b661bff02d32d4634f5
6
+ metadata.gz: 1d66248c13f74ccaa779db89359467e54c1ee18979683fcd42e62485ac5657345115985329f07be02f0ffe6f347334646e26bb920df1b1efad2d3ef55ab24d74
7
+ data.tar.gz: f395e256aca6a133fe684f3e28a94cbdca4f70ea6a2c565a63f30bb4f52144f62529a6b20c24d806e97a4ba0bb11a5ca0e2402d521c700f13bc5b1bb49331578
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Unreleased
2
2
 
3
+ # v0.25.1
4
+
5
+ - More reliable way to disable max_records_scan checks when loading records.
6
+
3
7
  # v0.25.0
4
8
 
5
9
  - Disable max_records_scan checks when loading records.
@@ -6,6 +6,18 @@ require 'frozen_record/backends'
6
6
  module FrozenRecord
7
7
  SlowQuery = Class.new(StandardError)
8
8
 
9
+ class << self
10
+ attr_accessor :enforce_max_records_scan
11
+
12
+ def ignore_max_records_scan
13
+ previous = enforce_max_records_scan
14
+ yield
15
+ ensure
16
+ self.enforce_max_records_scan = previous
17
+ end
18
+ end
19
+ @enforce_max_records_scan = true
20
+
9
21
  class Base
10
22
  extend ActiveSupport::DescendantsTracker
11
23
  extend ActiveModel::Naming
@@ -156,7 +168,7 @@ module FrozenRecord
156
168
  end
157
169
  @attributes = list_attributes(records).freeze
158
170
  define_attribute_methods(@attributes.to_a)
159
- records = with_max_records_scan(nil) { records.map { |r| load(r) }.freeze }
171
+ records = FrozenRecord.ignore_max_records_scan { records.map { |r| load(r) }.freeze }
160
172
  index_definitions.values.each { |index| index.build(records) }
161
173
  records
162
174
  end
@@ -202,7 +202,7 @@ module FrozenRecord
202
202
  end
203
203
  end
204
204
 
205
- if @klass.max_records_scan && records.size > @klass.max_records_scan
205
+ if FrozenRecord.enforce_max_records_scan && @klass.max_records_scan && records.size > @klass.max_records_scan
206
206
  raise SlowQuery, "Scanning #{records.size} records is too slow, the allowed maximum is #{@klass.max_records_scan}. Try to find a better index or consider an alternative storage"
207
207
  end
208
208
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FrozenRecord
4
- VERSION = '0.25.0'
4
+ VERSION = '0.25.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frozen_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier