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

Remove unnecessary call to resolve_column_aliases #657

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
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gemfile:
- gemfiles/activerecord_5.1.0.gemfile
- gemfiles/activerecord_5.2.2.gemfile
- gemfiles/activerecord_6.0.0.gemfile
- gemfiles/activerecord_master.gemfile
env:
- DB=sqlite
- DB=postgres
Expand All @@ -33,6 +34,12 @@ matrix:
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: 2.4.2
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: 2.2.6
gemfile: gemfiles/activerecord_master.gemfile
- rvm: 2.3.5
gemfile: gemfiles/activerecord_master.gemfile
- rvm: 2.4.2
gemfile: gemfiles/activerecord_master.gemfile
- rvm: 2.7.0
gemfile: gemfiles/activerecord_4.2.0.gemfile
- rvm: truffleruby-head
Expand All @@ -41,10 +48,14 @@ matrix:
gemfile: gemfiles/activerecord_5.0.2.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/activerecord_master.gemfile
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_5.0.2.gemfile
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_master.gemfile
allow_failures:
- rvm: ruby-head
- rvm: jruby-head
Expand Down
17 changes: 17 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,20 @@ appraise 'activerecord_6.0.0' do
gem 'sqlite3', '~> 1.4.0'
end
end

appraise 'activerecord_master' do
gem 'actionpack', github: 'rails/rails', require: 'action_pack'
gem 'activerecord', github: 'rails/rails', require: 'active_record'
gem 'activesupport', github: 'rails/rails', require: 'active_support/all'

platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jdbc-sqlite3'
gem 'jdbc-postgres'
end

platforms :ruby, :mswin, :mingw do
gem 'pg', '~> 1.1.4'
gem 'sqlite3', '~> 1.4.0'
end
end
20 changes: 20 additions & 0 deletions gemfiles/activerecord_master.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "actionpack", github: "rails/rails", require: "action_pack"
gem "activerecord", github: "rails/rails", require: "active_record"
gem "activesupport", github: "rails/rails", require: "active_support/all"

platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
gem "jdbc-sqlite3"
gem "jdbc-postgres"
end

platforms :ruby, :mswin, :mingw do
gem "pg", "~> 1.1.4"
gem "sqlite3", "~> 1.4.0"
end

gemspec path: "../"
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