Skip to content

Commit

Permalink
Fix version lookup for old ActiveRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
albus522 committed Aug 14, 2024
1 parent 86c9eff commit 8cc3104
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/delayed/backend/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def self.ready_to_run(worker_name, max_run_time)
end

def self.before_fork
if ::ActiveRecord.version >= Gem::Version.new('7.1.0')
if Gem::Version.new("7.1.0") <= ::ActiveRecord::VERSION::STRING
::ActiveRecord::Base.clear_all_connections!(:all)
else
::ActiveRecord::Base.clear_all_connections!
Expand Down
6 changes: 3 additions & 3 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
db_adapter ||= gemfile && gemfile[%r{gemfiles/(.*?)/}] && $1 # rubocop:disable Style/PerlBackrefs
db_adapter ||= "sqlite3"

if db_adapter == "trilogy" && ActiveRecord.version < Gem::Version.new("7.1")
trilogy_adapter_gem = Gem::Specification.find_by_name("activerecord-trilogy-adapter").gem_dir
require "#{trilogy_adapter_gem}/lib/trilogy_adapter/connection"
puts "Testing with db adapter: #{defined?(Rails)}"
if db_adapter == "trilogy" && Gem::Version.new("7.1") > ActiveRecord::VERSION::STRING
require "trilogy_adapter/connection"
ActiveSupport.on_load(:active_record) { extend TrilogyAdapter::Connection }
end

Expand Down

0 comments on commit 8cc3104

Please sign in to comment.