From 175359431c9355acdfaf2bbd145b7a798e5e92fb Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 1 Nov 2017 15:56:08 -0700 Subject: [PATCH 1/4] Use gem version of jdbcsqlite3-adapter --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3687175c..b83d8a9b 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'sqlite3', platforms: [:ruby] platforms :jruby do - gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5' + gem 'activerecord-jdbcsqlite3-adapter' end platforms :rbx do From bb55ee9122f7981e9b4774a32a2e3175bde8b054 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 1 Nov 2017 16:00:47 -0700 Subject: [PATCH 2/4] Avoid raise_in_transactional_callbacks warning --- test/paranoia_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/paranoia_test.rb b/test/paranoia_test.rb index 8c4c2d3f..79cafc65 100644 --- a/test/paranoia_test.rb +++ b/test/paranoia_test.rb @@ -5,6 +5,10 @@ test_framework = defined?(MiniTest::Test) ? MiniTest::Test : MiniTest::Unit::TestCase +if ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks=) + ActiveRecord::Base.raise_in_transactional_callbacks = true +end + def connect! ActiveRecord::Base.establish_connection :adapter => 'sqlite3', database: ':memory:' end From 7ccd9d428245e82cd9fd2ec28967e0855402c206 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 1 Nov 2017 19:12:23 -0700 Subject: [PATCH 3/4] Use rails 5.1 in Gemfile by default --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b83d8a9b..00aa35d8 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ platforms :rbx do gem 'rubinius-developer_tools' end -rails = ENV['RAILS'] || '~> 4.2.0' +rails = ENV['RAILS'] || '~> 5.1.0' gem 'rails', rails From 97623f17d66ff582af33beadae7ec1defe109ca3 Mon Sep 17 00:00:00 2001 From: Steve Rice Date: Thu, 13 Jul 2017 09:57:59 -0700 Subject: [PATCH 4/4] Fixes `really_destroy!` behavior with `sentinel_value` 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 --- lib/paranoia.rb | 2 +- test/paranoia_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/paranoia.rb b/lib/paranoia.rb index a2298953..187cab72 100644 --- a/lib/paranoia.rb +++ b/lib/paranoia.rb @@ -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 diff --git a/test/paranoia_test.rb b/test/paranoia_test.rb index 8c4c2d3f..d0380aa1 100644 --- a/test/paranoia_test.rb +++ b/test/paranoia_test.rb @@ -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