From 7a73f98266503c1680b016eda1f346dc6414a778 Mon Sep 17 00:00:00 2001 From: fatkodima Date: Wed, 11 Dec 2024 19:59:01 +0200 Subject: [PATCH] Fix checking for expression indexes support --- .../detectors/missing_unique_indexes.rb | 2 +- lib/active_record_doctor/utils.rb | 6 ------ test/setup.rb | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/active_record_doctor/detectors/missing_unique_indexes.rb b/lib/active_record_doctor/detectors/missing_unique_indexes.rb index d444a0e..3481823 100644 --- a/lib/active_record_doctor/detectors/missing_unique_indexes.rb +++ b/lib/active_record_doctor/detectors/missing_unique_indexes.rb @@ -66,7 +66,7 @@ def validations_without_indexes case_sensitive = validator.options.fetch(:case_sensitive, true) # Avoid a false positive if expression indexes are unsupported. - next if !case_sensitive && Utils.expression_indexes_unsupported? + next if !case_sensitive && !connection.supports_expression_index? validator.attributes.each do |attribute| columns = resolve_attributes(model, scope + [attribute]) diff --git a/lib/active_record_doctor/utils.rb b/lib/active_record_doctor/utils.rb index f2e1a2a..e2f8763 100644 --- a/lib/active_record_doctor/utils.rb +++ b/lib/active_record_doctor/utils.rb @@ -14,12 +14,6 @@ def mysql?(connection = ActiveRecord::Base.connection) def sqlite?(connection = ActiveRecord::Base.connection) connection.adapter_name == "SQLite" end - - def expression_indexes_unsupported?(connection = ActiveRecord::Base.connection) - sqlite?(connection) || - # Active Record is unable to correctly parse expression indexes for MySQL. - (mysql?(connection) && ActiveRecord::VERSION::STRING < "7.1") - end end end end diff --git a/test/setup.rb b/test/setup.rb index 54bd10b..6382233 100644 --- a/test/setup.rb +++ b/test/setup.rb @@ -146,7 +146,7 @@ def require_non_key_index_columns! end def require_expression_indexes! - skip("#{current_adapter} doesn't support expression indexes") if ActiveRecordDoctor::Utils.expression_indexes_unsupported? + skip("#{current_adapter} doesn't support expression indexes") if ActiveRecord::Base.connection.supports_expression_index? end def require_non_indexed_foreign_keys!