paranoia 2.6.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +14 -27
- data/CHANGELOG.md +22 -7
- data/Gemfile +1 -1
- data/lib/paranoia/version.rb +1 -1
- data/lib/paranoia.rb +33 -8
- data/paranoia.gemspec +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86ea97ca665a462c533110c63c1b277d440292839725fbe8b2e3bc8f295d8850
|
4
|
+
data.tar.gz: 403501a4e47840a726eee8eaeef9e38a4c44c041c6baee5b3cba20df368558d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6690c30c44ed3713090776c3236d4e502cc8369d9556765c689dea4e6ac6c92400cabb95e31afcc37fb7479bdb543125288b5512dca7dc964f33a023b46d1171
|
7
|
+
data.tar.gz: 5cacc8c926267c5de867b33ea74bde450b353618af43144a73da1aeb8878526510c71587c2720f88e96ad3eb97b90dd9489711b2200fa14faaa628bed7101b77
|
data/.github/workflows/build.yml
CHANGED
@@ -15,37 +15,24 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
fail-fast: false
|
17
17
|
matrix:
|
18
|
-
rails: ["~> 7.
|
19
|
-
ruby: ["3.
|
20
|
-
|
21
|
-
-
|
22
|
-
|
23
|
-
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
rails: '~> 6.0.0'
|
32
|
-
- ruby: 2.6
|
33
|
-
rails: '~> 5.2.0'
|
34
|
-
- ruby: 2.6
|
35
|
-
rails: '~> 5.1.0'
|
36
|
-
- ruby: 2.5
|
37
|
-
rails: '~> 6.0.0'
|
38
|
-
- ruby: 2.5
|
39
|
-
rails: '~> 5.2.0'
|
40
|
-
- ruby: 2.5
|
41
|
-
rails: '~> 5.1.0'
|
42
|
-
#os: ubuntu-latest
|
43
|
-
#arch: x64
|
18
|
+
rails: ["edge", "~> 7.2.0", "~> 7.1.0", "~> 7.0.0", "~> 6.1.0"]
|
19
|
+
ruby: ["3.3","3.2", "3.1", "3.0", "2.7"]
|
20
|
+
exclude:
|
21
|
+
- rails: "~> 7.2.0"
|
22
|
+
ruby: "3.0"
|
23
|
+
- rails: "~> 7.2.0"
|
24
|
+
ruby: "2.7"
|
25
|
+
- rails: "edge"
|
26
|
+
ruby: "3.0"
|
27
|
+
- rails: "edge"
|
28
|
+
ruby: "2.7"
|
29
|
+
|
30
|
+
|
44
31
|
|
45
32
|
env:
|
46
33
|
RAILS: ${{ matrix.rails }}
|
47
34
|
steps:
|
48
|
-
- uses: actions/checkout@
|
35
|
+
- uses: actions/checkout@v4
|
49
36
|
- uses: ruby/setup-ruby@v1
|
50
37
|
with:
|
51
38
|
ruby-version: ${{ matrix.ruby }}
|
data/CHANGELOG.md
CHANGED
@@ -1,22 +1,37 @@
|
|
1
1
|
# paranoia Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## 3.0.0 - August 13, 2024
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
_Tagged as 3.0 as Ruby + Rails version constraints have been modernised._
|
6
|
+
|
7
|
+
- [#564](https://github.com/rubysherpas/paranoia/pull/564) Support Rails edge
|
8
|
+
- [#563](https://github.com/rubysherpas/paranoia/pull/563) Support Rails 7.2
|
9
|
+
|
10
|
+
## 2.6.4 - July 20, 2024
|
11
|
+
|
12
|
+
* [#554](https://github.com/rubysherpas/paranoia/pull/554) Support prebuilt counter cache association list (#554)
|
13
|
+
[Joé Dupuis](https://github.com/JoeDupuis)
|
14
|
+
* [#551](https://github.com/rubysherpas/paranoia/pull/551) Fix: restore has_one with scope (#551)
|
15
|
+
[Paweł Charyło](https://github.com/zygzagZ)
|
16
|
+
* [#555](https://github.com/rubysherpas/paranoia/pull/555) 📝 Add Yard documentation for Paranoia::Query (#555)
|
17
|
+
[Clément Prod'homme](https://github.com/cprodhomme)
|
18
|
+
|
19
|
+
## 2.6.3 - Oct 12, 2023
|
20
|
+
|
21
|
+
* [#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
22
|
[Indyarocks](https://github.com/indyarocks)
|
8
23
|
|
9
|
-
## 2.6.2
|
24
|
+
## 2.6.2 - Jun 6, 2023
|
10
25
|
|
11
|
-
* [#441](https://github.com/rubysherpas/paranoia/pull/441) Recursive restore with has_many/one through assocs (#441)
|
26
|
+
* [#441](https://github.com/rubysherpas/paranoia/pull/441) Recursive restore with has_many/one through assocs (#441)
|
12
27
|
[Emil Ong](https://github.com/emilong)
|
13
28
|
|
14
|
-
## 2.6.1
|
29
|
+
## 2.6.1 - Nov 16, 2022
|
15
30
|
|
16
31
|
* [#535](https://github.com/rubysherpas/paranoia/pull/535) Allow to skip updating paranoia_destroy_attributes for records while really_destroy!
|
17
32
|
[Anton Bogdanov](https://github.com/kortirso)
|
18
33
|
|
19
|
-
## 2.6.0
|
34
|
+
## 2.6.0 - Mar 23, 2022
|
20
35
|
|
21
36
|
* [#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
37
|
* [#476](https://github.com/rubysherpas/paranoia/pull/476) Fix syntax error in documentation.
|
data/Gemfile
CHANGED
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
|
data/paranoia.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.required_rubygems_version = ">= 1.3.6"
|
24
24
|
|
25
|
-
s.required_ruby_version = '>= 2.
|
25
|
+
s.required_ruby_version = '>= 2.7'
|
26
26
|
|
27
|
-
s.add_dependency 'activerecord', '>=
|
27
|
+
s.add_dependency 'activerecord', '>= 6', '< 8.1'
|
28
28
|
|
29
29
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
30
30
|
s.add_development_dependency "rake"
|
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:
|
4
|
+
version: 3.0.0
|
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-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '6'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,14 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '2.
|
102
|
+
version: '2.7'
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: 1.3.6
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.4.
|
109
|
+
rubygems_version: 3.4.10
|
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,
|