Skip to content

Commit

Permalink
Fixes really_destroy! behavior with sentinel_value
Browse files Browse the repository at this point in the history
This removes the assumption from `really_destroy!` that there is
only one column value, the deletion date, that needs to be updated
on a model that is being `really_destroy!`ed. Instead, use the
defined `paranoia_destroy_attributes` as they are used in `destroy`
and other calls.

This prevents an issue where the DBMS will complain when trying to
`really_destroy!` one of these models, given that paranoia is
attempting to insert a DateTime value into a boolean (or otherly-
typed) column.

Fixes #326
  • Loading branch information
steverice authored and jhawthorn committed Nov 2, 2017
1 parent ea0a0ce commit 97623f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def really_destroy!
association_data.really_destroy!
end
end
write_attribute(paranoia_column, current_time_from_proper_timezone)
update_columns(paranoia_destroy_attributes)
destroy_without_paranoia
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/paranoia_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ def test_really_destroy_behavior_for_callbacks
assert model.instance_variable_get(:@real_destroy_callback_called)
end

def test_really_destroy_behavior_for_active_column_model
model = ActiveColumnModel.new
model.save
model.really_destroy!

refute ParanoidModel.unscoped.exists?(model.id)
end

def test_really_delete
model = ParanoidModel.new
model.save
Expand Down

0 comments on commit 97623f1

Please sign in to comment.