From 96fb64a1721babb163f650e21f1b86e29ea4a4f5 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Mon, 26 Oct 2020 15:14:12 -0500 Subject: [PATCH 1/3] Remove unnecessary call to resolve_column_aliases --- lib/cancan/model_adapters/active_record_5_adapter.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/cancan/model_adapters/active_record_5_adapter.rb b/lib/cancan/model_adapters/active_record_5_adapter.rb index f7c5df8d..1326aeec 100644 --- a/lib/cancan/model_adapters/active_record_5_adapter.rb +++ b/lib/cancan/model_adapters/active_record_5_adapter.rb @@ -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) @@ -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) From c6e14266d9bcc3b6c834f977fe14034777cbaa07 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Mon, 26 Oct 2020 15:19:51 -0500 Subject: [PATCH 2/3] Test against rails master --- .travis.yml | 7 +++++++ Appraisals | 17 +++++++++++++++++ gemfiles/activerecord_master.gemfile | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 gemfiles/activerecord_master.gemfile diff --git a/.travis.yml b/.travis.yml index 4ab62bf7..71618575 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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: jruby-9.1.17.0 diff --git a/Appraisals b/Appraisals index 9fd8ce0c..4e685555 100644 --- a/Appraisals +++ b/Appraisals @@ -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 diff --git a/gemfiles/activerecord_master.gemfile b/gemfiles/activerecord_master.gemfile new file mode 100644 index 00000000..739e08ba --- /dev/null +++ b/gemfiles/activerecord_master.gemfile @@ -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: "../" From e45fd35a6c110d950f0e0dc21c1ac569e0492290 Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Tue, 27 Oct 2020 15:03:20 -0500 Subject: [PATCH 3/3] add jruby ignores --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 71618575..3b19f86c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,14 +42,19 @@ matrix: gemfile: gemfiles/activerecord_master.gemfile - rvm: 2.7.0 gemfile: gemfiles/activerecord_4.2.0.gemfile + - rvm: jruby-9.1.17.0 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