frozen_record 0.25.0 → 0.25.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/frozen_record/base.rb +14 -1
- data/lib/frozen_record/compact.rb +1 -1
- data/lib/frozen_record/scope.rb +1 -1
- data/lib/frozen_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55cfe5dc540e6f5aa6d4a188a45297e5daae39c67b6f79a029ed12a1333d2a17
|
4
|
+
data.tar.gz: 68ec4931e6cd4c24dc95da423b4d32f61f789ebb38e8012ad16f12db9a0d389b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3bbf2f250846efd3679e39a7aea8628bfdea01c84a31cab342d5348e4a41bff3655a1f4e4158b461e2084866113c0a110b676664087ccb1b735c5d66e330cd3
|
7
|
+
data.tar.gz: e3bb79694ba6bb4b430cc378bad2c787a41bf71ec2834eb218d10243e0cb24d6573ef19661a454c613ede947dd33eaccc75a61395259533e2aaedb6a3089f565
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
- Also disable max_records_scan when loading `Compact` records.
|
4
|
+
|
5
|
+
# v0.25.2
|
6
|
+
|
7
|
+
- Fix FrozenRecord.ignore_max_records_scan not applying
|
8
|
+
|
9
|
+
# v0.25.1
|
10
|
+
|
11
|
+
- More reliable way to disable max_records_scan checks when loading records.
|
12
|
+
|
3
13
|
# v0.25.0
|
4
14
|
|
5
15
|
- Disable max_records_scan checks when loading records.
|
data/lib/frozen_record/base.rb
CHANGED
@@ -6,6 +6,19 @@ 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
|
+
self.enforce_max_records_scan = false
|
15
|
+
yield
|
16
|
+
ensure
|
17
|
+
self.enforce_max_records_scan = previous
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@enforce_max_records_scan = true
|
21
|
+
|
9
22
|
class Base
|
10
23
|
extend ActiveSupport::DescendantsTracker
|
11
24
|
extend ActiveModel::Naming
|
@@ -156,7 +169,7 @@ module FrozenRecord
|
|
156
169
|
end
|
157
170
|
@attributes = list_attributes(records).freeze
|
158
171
|
define_attribute_methods(@attributes.to_a)
|
159
|
-
records =
|
172
|
+
records = FrozenRecord.ignore_max_records_scan { records.map { |r| load(r) }.freeze }
|
160
173
|
index_definitions.values.each { |index| index.build(records) }
|
161
174
|
records
|
162
175
|
end
|
@@ -19,7 +19,7 @@ module FrozenRecord
|
|
19
19
|
@attributes = list_attributes(records).freeze
|
20
20
|
build_attributes_cache
|
21
21
|
define_attribute_methods(@attributes.to_a)
|
22
|
-
records = records.map { |r| load(r) }.freeze
|
22
|
+
records = FrozenRecord.ignore_max_records_scan { records.map { |r| load(r) }.freeze }
|
23
23
|
index_definitions.values.each { |index| index.build(records) }
|
24
24
|
records
|
25
25
|
end
|
data/lib/frozen_record/scope.rb
CHANGED
@@ -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
|
|