paper_trail 7.1.3 → 8.0.0
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/lib/paper_trail/record_trail.rb +2 -7
- data/lib/paper_trail/reifiers/belongs_to.rb +1 -1
- data/lib/paper_trail/reifiers/has_many.rb +1 -1
- data/lib/paper_trail/reifiers/has_many_through.rb +1 -1
- data/lib/paper_trail/reifiers/has_one.rb +1 -1
- data/lib/paper_trail/serializers/json.rb +8 -18
- data/lib/paper_trail/version_concern.rb +1 -4
- data/lib/paper_trail/version_number.rb +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91bf6fabed9a524ca3251a32df08bf75daaf8e59
|
4
|
+
data.tar.gz: 98c9208fcb6946ce58943ff3188ddee60f90a0de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f75fd7f32568e15f48194cbd099152f75d0e38bd3e3e5f173c16f20919ad3766f9ccfebb69203558946abcd48d1da017a80749c1c957093af589478fa187b2cb
|
7
|
+
data.tar.gz: b4916a9fae7ce82d73d98baefb6d63d41482c0e7dc090751b2ddf7543876a070782c16a233f1b89617932ec1fb92d9810995b67ab4196d7bff94ecc471e2f912
|
@@ -1,10 +1,7 @@
|
|
1
1
|
module PaperTrail
|
2
2
|
# Represents the "paper trail" for a single record.
|
3
3
|
class RecordTrail
|
4
|
-
|
5
|
-
# removed when support for ActiveRecord < 4.2 is dropped.
|
6
|
-
RAILS_GTE_5_1 = ::ActiveRecord.respond_to?(:gem_version) &&
|
7
|
-
::ActiveRecord.gem_version >= ::Gem::Version.new("5.1.0.beta1")
|
4
|
+
RAILS_GTE_5_1 = ::ActiveRecord.gem_version >= ::Gem::Version.new("5.1.0.beta1")
|
8
5
|
|
9
6
|
def initialize(record)
|
10
7
|
@record = record
|
@@ -477,9 +474,7 @@ module PaperTrail
|
|
477
474
|
if @in_after_callback && RAILS_GTE_5_1
|
478
475
|
@record.attribute_before_last_save(attr_name.to_s)
|
479
476
|
else
|
480
|
-
|
481
|
-
# attribute_was is no longer private.
|
482
|
-
@record.send(:attribute_was, attr_name.to_s)
|
477
|
+
@record.attribute_was(attr_name.to_s)
|
483
478
|
end
|
484
479
|
end
|
485
480
|
|
@@ -37,7 +37,7 @@ module PaperTrail
|
|
37
37
|
# @api private
|
38
38
|
def load_version(assoc, id, transaction_id, version_at)
|
39
39
|
assoc.klass.paper_trail.version_class.
|
40
|
-
where("item_type = ?", assoc.
|
40
|
+
where("item_type = ?", assoc.klass.name).
|
41
41
|
where("item_id = ?", id).
|
42
42
|
where("created_at >= ? OR transaction_id = ?", version_at, transaction_id).
|
43
43
|
order("id").limit(1).first
|
@@ -98,7 +98,7 @@ module PaperTrail
|
|
98
98
|
select("MIN(version_id)").
|
99
99
|
where("foreign_key_name = ?", assoc.foreign_key).
|
100
100
|
where("foreign_key_id = ?", model.id).
|
101
|
-
where("#{version_table}.item_type = ?", assoc.
|
101
|
+
where("#{version_table}.item_type = ?", assoc.klass.name).
|
102
102
|
where("created_at >= ? OR transaction_id = ?", version_at, tx_id).
|
103
103
|
group("item_id").
|
104
104
|
to_sql
|
@@ -73,7 +73,7 @@ module PaperTrail
|
|
73
73
|
def load_versions_for_hmt_association(assoc, ids, tx_id, version_at)
|
74
74
|
version_id_subquery = assoc.klass.paper_trail.version_class.
|
75
75
|
select("MIN(id)").
|
76
|
-
where("item_type = ?", assoc.
|
76
|
+
where("item_type = ?", assoc.klass.name).
|
77
77
|
where("item_id IN (?)", ids).
|
78
78
|
where(
|
79
79
|
"created_at >= ? OR transaction_id = ?",
|
@@ -36,7 +36,7 @@ module PaperTrail
|
|
36
36
|
model.class.paper_trail.version_class.joins(:version_associations).
|
37
37
|
where("version_associations.foreign_key_name = ?", assoc.foreign_key).
|
38
38
|
where("version_associations.foreign_key_id = ?", model.id).
|
39
|
-
where("#{version_table_name}.item_type = ?", assoc.
|
39
|
+
where("#{version_table_name}.item_type = ?", assoc.klass.name).
|
40
40
|
where("created_at >= ? OR transaction_id = ?", version_at, transaction_id).
|
41
41
|
order("#{version_table_name}.id ASC").
|
42
42
|
first
|
@@ -4,13 +4,6 @@ module PaperTrail
|
|
4
4
|
module Serializers
|
5
5
|
# An alternate serializer for, e.g. `versions.object`.
|
6
6
|
module JSON
|
7
|
-
E_WHERE_OBJ_CHANGES = <<-STR.squish.freeze
|
8
|
-
where_object_changes has a known issue. When reading json from a text
|
9
|
-
column, it may return more records than expected. Instead of a warning,
|
10
|
-
this method may raise an error in the future. Please join the discussion
|
11
|
-
at https://github.com/airblade/paper_trail/issues/803
|
12
|
-
STR
|
13
|
-
|
14
7
|
extend self # makes all instance methods become module methods as well
|
15
8
|
|
16
9
|
def load(string)
|
@@ -39,17 +32,14 @@ module PaperTrail
|
|
39
32
|
end
|
40
33
|
end
|
41
34
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# Need to check first (before) and secondary (after) fields
|
51
|
-
arel_field.matches("%\"#{field}\":[#{json_value},%").
|
52
|
-
or(arel_field.matches("%\"#{field}\":[%,#{json_value}]%"))
|
35
|
+
def where_object_changes_condition(*)
|
36
|
+
raise <<-STR.squish.freeze
|
37
|
+
where_object_changes no longer supports reading json from a text
|
38
|
+
column. The old implementation was inaccurate, returning more records
|
39
|
+
than you wanted. This feature was deprecated in 7.1.0 and removed in
|
40
|
+
8.0.0. The json and jsonb datatypes are still supported. See the
|
41
|
+
discussion at https://github.com/airblade/paper_trail/issues/803
|
42
|
+
STR
|
53
43
|
end
|
54
44
|
end
|
55
45
|
end
|
@@ -12,10 +12,7 @@ module PaperTrail
|
|
12
12
|
extend ::ActiveSupport::Concern
|
13
13
|
|
14
14
|
included do
|
15
|
-
|
16
|
-
# removed when support for ActiveRecord < 4.2 is dropped.
|
17
|
-
if ::ActiveRecord.respond_to?(:gem_version) &&
|
18
|
-
::ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
15
|
+
if ::ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
19
16
|
belongs_to :item, polymorphic: true, optional: true
|
20
17
|
else
|
21
18
|
belongs_to :item, polymorphic: true
|
@@ -5,9 +5,9 @@ module PaperTrail
|
|
5
5
|
# because of this confusion, but it's not worth the breaking change.
|
6
6
|
# People are encouraged to use `PaperTrail.gem_version` instead.
|
7
7
|
module VERSION
|
8
|
-
MAJOR =
|
9
|
-
MINOR =
|
10
|
-
TINY =
|
8
|
+
MAJOR = 8
|
9
|
+
MINOR = 0
|
10
|
+
TINY = 0
|
11
11
|
PRE = nil
|
12
12
|
|
13
13
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Stewart
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '4.
|
21
|
+
version: '4.2'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '5.2'
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '4.
|
31
|
+
version: '4.2'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '5.2'
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '4.
|
97
|
+
version: '4.2'
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '5.2'
|
@@ -104,7 +104,7 @@ dependencies:
|
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '4.
|
107
|
+
version: '4.2'
|
108
108
|
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '5.2'
|
@@ -323,7 +323,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
323
323
|
requirements:
|
324
324
|
- - ">="
|
325
325
|
- !ruby/object:Gem::Version
|
326
|
-
version: 2.
|
326
|
+
version: 2.2.0
|
327
327
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
328
328
|
requirements:
|
329
329
|
- - ">="
|