paranoia 2.6.3 → 2.6.4
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 +4 -4
- data/.github/workflows/build.yml +1 -1
- data/CHANGELOG.md +16 -6
- data/lib/paranoia/version.rb +1 -1
- data/lib/paranoia.rb +33 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c181b837c0b9148cea47aaac1d370b142037943ee9e115ca14c2c1ae794c384
|
4
|
+
data.tar.gz: 9bbd8a2b61fe1a68871f11af0673ddb9ae83ae3bb51ff887354f758d300cac11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8824844107b4cd59840c174b99a2ce7f92ed03762ec5fffcf912f26be59a5fe52480a93b66515631b608ee6c575e664444b8b48414e3efef757ef42250adf32
|
7
|
+
data.tar.gz: cf0fc54e5a6b8906ad3cbf864c3a40250b6e7f9a2775f911e33e4ae420a5354c0ddde54936e033b9fc15be0e0dabc58b5db3a70a9b0f17b2ba610d1dfb628e5e
|
data/.github/workflows/build.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,22 +1,32 @@
|
|
1
1
|
# paranoia Changelog
|
2
2
|
|
3
|
-
## 2.6.
|
3
|
+
## 2.6.4 - July 20, 2024
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
Add support for [Rails 7.2](https://github.com/rails/rails/releases/tag/v7.2.0)
|
6
|
+
|
7
|
+
* [#554](https://github.com/rubysherpas/paranoia/pull/554) Support prebuilt counter cache association list (#554)
|
8
|
+
[Joé Dupuis](https://github.com/JoeDupuis)
|
9
|
+
* [#551](https://github.com/rubysherpas/paranoia/pull/551) Fix: restore has_one with scope (#551)
|
10
|
+
[Paweł Charyło](https://github.com/zygzagZ)
|
11
|
+
* [#555](https://github.com/rubysherpas/paranoia/pull/555) 📝 Add Yard documentation for Paranoia::Query (#555)
|
12
|
+
[Clément Prod'homme](https://github.com/cprodhomme)
|
13
|
+
|
14
|
+
## 2.6.3 - Oct 12, 2023
|
15
|
+
|
16
|
+
* [#548](https://github.com/rubysherpas/paranoia/pull/548) Add support for [Rails 7.1](https://github.com/rails/rails/releases/tag/v7.1.0) (#548)
|
7
17
|
[Indyarocks](https://github.com/indyarocks)
|
8
18
|
|
9
|
-
## 2.6.2
|
19
|
+
## 2.6.2 - Jun 6, 2023
|
10
20
|
|
11
21
|
* [#441](https://github.com/rubysherpas/paranoia/pull/441) Recursive restore with has_many/one through assocs (#441)
|
12
22
|
[Emil Ong](https://github.com/emilong)
|
13
23
|
|
14
|
-
## 2.6.1
|
24
|
+
## 2.6.1 - Nov 16, 2022
|
15
25
|
|
16
26
|
* [#535](https://github.com/rubysherpas/paranoia/pull/535) Allow to skip updating paranoia_destroy_attributes for records while really_destroy!
|
17
27
|
[Anton Bogdanov](https://github.com/kortirso)
|
18
28
|
|
19
|
-
## 2.6.0
|
29
|
+
## 2.6.0 - Mar 23, 2022
|
20
30
|
|
21
31
|
* [#512](https://github.com/rubysherpas/paranoia/pull/512) Quote table names; Mysql 8 has keywords that might match table names which cause an exception.
|
22
32
|
* [#476](https://github.com/rubysherpas/paranoia/pull/476) Fix syntax error in documentation.
|
data/lib/paranoia/version.rb
CHANGED
data/lib/paranoia.rb
CHANGED
@@ -24,6 +24,7 @@ module Paranoia
|
|
24
24
|
module Query
|
25
25
|
def paranoid? ; true ; end
|
26
26
|
|
27
|
+
# If you want to find all records, even those which are deleted
|
27
28
|
def with_deleted
|
28
29
|
if ActiveRecord::VERSION::STRING >= "4.1"
|
29
30
|
return unscope where: paranoia_column
|
@@ -31,6 +32,7 @@ module Paranoia
|
|
31
32
|
all.tap { |x| x.default_scoped = false }
|
32
33
|
end
|
33
34
|
|
35
|
+
# If you want to find only the deleted records
|
34
36
|
def only_deleted
|
35
37
|
if paranoia_sentinel_value.nil?
|
36
38
|
return with_deleted.where.not(paranoia_column => paranoia_sentinel_value)
|
@@ -45,6 +47,7 @@ module Paranoia
|
|
45
47
|
end
|
46
48
|
alias_method :deleted, :only_deleted
|
47
49
|
|
50
|
+
# If you want to restore a record
|
48
51
|
def restore(id_or_ids, opts = {})
|
49
52
|
ids = Array(id_or_ids).flatten
|
50
53
|
any_object_instead_of_id = ids.any? { |id| ActiveRecord::Base === id }
|
@@ -173,8 +176,25 @@ module Paranoia
|
|
173
176
|
|
174
177
|
private
|
175
178
|
|
179
|
+
def counter_cache_disabled?
|
180
|
+
defined?(@_disable_counter_cache) && @_disable_counter_cache
|
181
|
+
end
|
182
|
+
|
183
|
+
def counter_cached_association_names
|
184
|
+
return [] if counter_cache_disabled?
|
185
|
+
super
|
186
|
+
end
|
187
|
+
|
176
188
|
def each_counter_cached_associations
|
177
|
-
|
189
|
+
return [] if counter_cache_disabled?
|
190
|
+
|
191
|
+
if defined?(super)
|
192
|
+
super
|
193
|
+
else
|
194
|
+
counter_cached_association_names.each do |name|
|
195
|
+
yield association(name)
|
196
|
+
end
|
197
|
+
end
|
178
198
|
end
|
179
199
|
|
180
200
|
def paranoia_restore_attributes
|
@@ -193,6 +213,16 @@ module Paranoia
|
|
193
213
|
timestamp_attributes_for_update_in_model.each_with_object({}) { |attr,hash| hash[attr] = current_time_from_proper_timezone }
|
194
214
|
end
|
195
215
|
|
216
|
+
def paranoia_find_has_one_target(association)
|
217
|
+
association_foreign_key = association.options[:through].present? ? association.klass.primary_key : association.foreign_key
|
218
|
+
association_find_conditions = { association_foreign_key => self.id }
|
219
|
+
association_find_conditions[association.type] = self.class.name if association.type
|
220
|
+
|
221
|
+
scope = association.klass.only_deleted.where(association_find_conditions)
|
222
|
+
scope = scope.merge(association.scope) if association.scope
|
223
|
+
scope.first
|
224
|
+
end
|
225
|
+
|
196
226
|
# restore associated records that have been soft deleted when
|
197
227
|
# we called #destroy
|
198
228
|
def restore_associated_records(recovery_window_range = nil)
|
@@ -216,13 +246,8 @@ module Paranoia
|
|
216
246
|
end
|
217
247
|
|
218
248
|
if association_data.nil? && association.macro.to_s == "has_one"
|
219
|
-
|
220
|
-
|
221
|
-
association_foreign_key = association.options[:through].present? ? association.klass.primary_key : association.foreign_key
|
222
|
-
association_find_conditions = { association_foreign_key => self.id }
|
223
|
-
association_find_conditions[association.type] = self.class.name if association.type
|
224
|
-
|
225
|
-
association_class.only_deleted.where(association_find_conditions).first
|
249
|
+
if association.klass.paranoid?
|
250
|
+
paranoia_find_has_one_target(association)
|
226
251
|
.try!(:restore, recursive: true, :recovery_window_range => recovery_window_range)
|
227
252
|
end
|
228
253
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paranoia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radarlistener@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: 1.3.6
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.5.11
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
|