From 3847abdae6d19864f002510be920f446a150fe35 Mon Sep 17 00:00:00 2001 From: James Woodrow Date: Sun, 12 Nov 2023 15:59:02 +0100 Subject: [PATCH] Add condition to only use SchemaReflection if ActiveRecord >= 7.1 --- .../connection_adapters/makara_abstract_adapter.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/active_record/connection_adapters/makara_abstract_adapter.rb b/lib/active_record/connection_adapters/makara_abstract_adapter.rb index caf928c6..6c8e889d 100644 --- a/lib/active_record/connection_adapters/makara_abstract_adapter.rb +++ b/lib/active_record/connection_adapters/makara_abstract_adapter.rb @@ -212,8 +212,12 @@ def initialize(proxy) @proxy = proxy @owner = nil @pool = nil - schema_reflection = ActiveRecord::ConnectionAdapters::SchemaReflection.new(nil).load!(@proxy) - @schema_cache = ActiveRecord::ConnectionAdapters::BoundSchemaReflection.new(schema_reflection, @proxy) + if ActiveRecord.version >= Gem::Version.new('7.1.0') + schema_reflection = ActiveRecord::ConnectionAdapters::SchemaReflection.new(nil).load!(@proxy) + @schema_cache = ActiveRecord::ConnectionAdapters::BoundSchemaReflection.new(schema_reflection, @proxy) + else + @schema_cache = ActiveRecord::ConnectionAdapters::SchemaCache.new @proxy + end @idle_since = Concurrent.monotonic_time @adapter = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(@proxy) end