Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking for expression indexes support #196

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 0 additions & 6 deletions lib/active_record_doctor/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
Loading