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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/frozen_record/base.rb +13 -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: 2c4f3cb4248d83050752933b1a2c48d0bf0914a73e695932650a03cae9feffa0
|
4
|
+
data.tar.gz: fb8517287957255269ffec7ab7bac5740c6d7e45b4f1c3c0b321ce4fc5badf4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d66248c13f74ccaa779db89359467e54c1ee18979683fcd42e62485ac5657345115985329f07be02f0ffe6f347334646e26bb920df1b1efad2d3ef55ab24d74
|
7
|
+
data.tar.gz: f395e256aca6a133fe684f3e28a94cbdca4f70ea6a2c565a63f30bb4f52144f62529a6b20c24d806e97a4ba0bb11a5ca0e2402d521c700f13bc5b1bb49331578
|
data/CHANGELOG.md
CHANGED
data/lib/frozen_record/base.rb
CHANGED
@@ -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 =
|
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
|
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
|
|