Skip to content

Commit

Permalink
Remove unnecessary call to resolve_column_aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiculescu committed Oct 26, 2020
1 parent 695d9b2 commit 96fb64a
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/cancan/model_adapters/active_record_5_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def build_relation(*where_conditions)
end
end

# Rails 4.2 deprecates `sanitize_sql_hash_for_conditions`
def sanitize_sql(conditions)
if conditions.is_a?(Hash)
sanitize_sql_activerecord5(conditions)
Expand All @@ -46,11 +45,7 @@ def sanitize_sql_activerecord5(conditions)
table_metadata = ActiveRecord::TableMetadata.new(@model_class, table)
predicate_builder = ActiveRecord::PredicateBuilder.new(table_metadata)

conditions = predicate_builder.resolve_column_aliases(conditions)

conditions.stringify_keys!

predicate_builder.build_from_hash(conditions).map { |b| visit_nodes(b) }.join(' AND ')
predicate_builder.build_from_hash(conditions.stringify_keys).map { |b| visit_nodes(b) }.join(' AND ')
end

def visit_nodes(node)
Expand Down

0 comments on commit 96fb64a

Please sign in to comment.