From e35c3f4b3d46603b65b6c9795b39e427d5ff65bf Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Mon, 2 Sep 2024 09:37:08 +0100 Subject: [PATCH] Support binary encryption on PostgreSQL for Rails 8 Support was added in https://github.com/rails/rails/pull/52729, so we can remove the check for Rails 8. --- Rakefile | 2 +- lib/solid_cache/engine.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 0a17dec..fdc6c00 100644 --- a/Rakefile +++ b/Rakefile @@ -36,7 +36,7 @@ end configs.each do |config| namespace :test do task config do - if config.to_s.start_with?("encrypted") && ENV["TARGET_DB"] == "postgres" + if config.to_s.start_with?("encrypted") && ENV["TARGET_DB"] == "postgres" && Rails::VERSION::MAJOR <= 7 puts "Skipping encrypted tests on PostgreSQL as binary encrypted columns are not supported by Rails yet" next end diff --git a/lib/solid_cache/engine.rb b/lib/solid_cache/engine.rb index f33b7ac..c3ac141 100644 --- a/lib/solid_cache/engine.rb +++ b/lib/solid_cache/engine.rb @@ -37,9 +37,9 @@ class Engine < ::Rails::Engine end config.after_initialize do - if SolidCache.configuration.encrypt? && SolidCache::Record.connection.adapter_name == "PostgreSQL" + if SolidCache.configuration.encrypt? && Record.connection.adapter_name == "PostgreSQL" && Rails::VERSION::MAJOR <= 7 raise \ - "Cannot enable encryption for Solid Cache: Active Record Encryption does not currently support " \ + "Cannot enable encryption for Solid Cache: in Rails 7, Active Record Encryption does not support " \ "encrypting binary columns on PostgreSQL" end end