Add deprecation warning to where_object_changes
See discussion at https://github.com/airblade/paper_trail/issues/803
This commit is contained in:
parent
b5500f1003
commit
6f452e4044
|
@ -11,6 +11,8 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
|
|||
|
||||
### Added
|
||||
|
||||
- [#803](https://github.com/airblade/paper_trail/issues/803)
|
||||
Deprecate `where_object_changes` when reading json from a text column
|
||||
- [#976](https://github.com/airblade/paper_trail/pull/976)
|
||||
`PaperTrail.whodunnit` accepts a `Proc`
|
||||
|
||||
|
|
|
@ -4,6 +4,13 @@ module PaperTrail
|
|||
module Serializers
|
||||
# An alternate serializer for, e.g. `versions.object`.
|
||||
module JSON
|
||||
E_WHERE_OBJ_CHANGES = <<-STR.squish.freeze
|
||||
where_object_changes has a known issue. When reading json from a text
|
||||
column, it may return more records than expected. Instead of a warning,
|
||||
this method may raise an error in the future. Please join the discussion
|
||||
at https://github.com/airblade/paper_trail/issues/803
|
||||
STR
|
||||
|
||||
extend self # makes all instance methods become module methods as well
|
||||
|
||||
def load(string)
|
||||
|
@ -35,6 +42,8 @@ module PaperTrail
|
|||
# Returns a SQL LIKE condition to be used to match the given field and
|
||||
# value in the serialized `object_changes`.
|
||||
def where_object_changes_condition(arel_field, field, value)
|
||||
::ActiveSupport::Deprecation.warn(E_WHERE_OBJ_CHANGES)
|
||||
|
||||
# Convert to JSON to handle strings and nulls correctly.
|
||||
json_value = value.to_json
|
||||
|
||||
|
|
|
@ -225,8 +225,6 @@ module PaperTrail
|
|||
end
|
||||
|
||||
context "YAML serializer" do
|
||||
specify { expect(PaperTrail.serializer).to be PaperTrail::Serializers::YAML }
|
||||
|
||||
it "locates versions according to their `object_changes` contents" do
|
||||
expect(
|
||||
widget.versions.where_object_changes(name: name)
|
||||
|
@ -248,7 +246,13 @@ module PaperTrail
|
|||
|
||||
context "JSON serializer" do
|
||||
before(:all) { PaperTrail.serializer = PaperTrail::Serializers::JSON }
|
||||
specify { expect(PaperTrail.serializer).to be PaperTrail::Serializers::JSON }
|
||||
before do
|
||||
unless override
|
||||
expect(::ActiveSupport::Deprecation).to(
|
||||
receive(:warn).at_least(:once).with(/^where_object_changes/)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it "locates versions according to their `object_changes` contents" do
|
||||
expect(
|
||||
|
|
Loading…
Reference in New Issue