diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8529ba1..f471b08 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -39,8 +39,6 @@ jobs: matrix: # just define specific versions for each rails version include: - - ruby: 2.6 - rails: 5.2 - ruby: 2.6 rails: "6.0" - ruby: "3.0" diff --git a/README.md b/README.md index bff4b6a..e862db7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ user_1.posts.union(user_2.posts).union(Post.published) user_1.posts.union_all(user_2.posts) ``` -ActiveRecordUnion is tested against Rails 5.0, 5.1, and 5.2. It should also work on Rails 4.2. It may or may not work on Rails 4.0/4.1. +ActiveRecordUnion is tested against Rails 6.0, 6.1, 7.0, 7.1, 7.2 and 8.0. If you are using Postgres, you might alternatively check out [ActiveRecordExtended](https://github.com/georgekaraszi/ActiveRecordExtended) which includes support for unions as well as other goodies. @@ -218,7 +218,7 @@ This public domain dedication follows the the CC0 1.0 at https://creativecommons 1. Install MySQL and PostgreSQL. 2. You need to be able to connect to a local MySQL and Postgres database as the default user, so the specs can create a `test_active_record_union` database. To set up the users this test expects, execute `bin/create-db-users` (or set the environment variables referenced in `spec/support/databases.rb`). 3. Run `rake` to test with all supported Rails versions. All needed dependencies will be installed via Bundler (`gem install bundler` if you happen not to have Bundler yet). - 4. Run `rake test_rails_4_2` or `rake test_rails_5_2` etc. to test a specific Rails version. + 4. Run `rake test_rails_8_0` or `rake test_rails_7_2` etc. to test a specific Rails version. 4. There is also a `bin/console` command to load up a REPL for playing around 5. Commit your changes (`git commit -am 'Add some feature'`) 6. Push to the branch (`git push origin my-new-feature`) diff --git a/active_record_union.gemspec b/active_record_union.gemspec index eeb82c0..89a77ef 100644 --- a/active_record_union.gemspec +++ b/active_record_union.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.files.grep(%r{^bin/}) spec.require_paths = ["lib"] - spec.add_dependency "activerecord", ">= 5.2" + spec.add_dependency "activerecord", ">= 6.0" spec.add_development_dependency "bundler" spec.add_development_dependency "rake" diff --git a/lib/active_record_union/active_record/relation/union.rb b/lib/active_record_union/active_record/relation/union.rb index 13e1a8d..57d1c34 100644 --- a/lib/active_record_union/active_record/relation/union.rb +++ b/lib/active_record_union/active_record/relation/union.rb @@ -41,41 +41,8 @@ def set_operation(operation, relation_or_where_arg, *args) build_union_relation(from, other) end - if ActiveRecord.gem_version >= Gem::Version.new('5.2.0.beta2') - # Since Rails 5.2, binds are maintained only in the Arel AST. - def build_union_relation(arel_table_alias, _other) - self.klass.unscoped.from(arel_table_alias) - end - elsif ActiveRecord::VERSION::MAJOR >= 5 - # In Rails >= 5.0, < 5.2, binds are maintained only in ActiveRecord - # relations and clauses. - def build_union_relation(arel_table_alias, other) - relation = self.klass.unscoped.spawn - relation.from_clause = - UnionFromClause.new(arel_table_alias, nil, - self.bound_attributes + other.bound_attributes) - relation - end - - class UnionFromClause < ActiveRecord::Relation::FromClause - def initialize(value, name, bound_attributes) - super(value, name) - @bound_attributes = bound_attributes - end - - def binds - @bound_attributes - end - end - else - # In Rails 4.x, binds are maintained in both ActiveRecord relations and - # clauses and also in their Arel ASTs. - def build_union_relation(arel_table_alias, other) - relation = self.klass.unscoped.from(arel_table_alias) - relation.bind_values = self.arel.bind_values + self.bind_values + - other.arel.bind_values + other.bind_values - relation - end + def build_union_relation(arel_table_alias, _other) + self.klass.unscoped.from(arel_table_alias) end def verify_relations_for_set_operation!(operation, *relations) diff --git a/rails_5.2.gemfile b/rails_5.2.gemfile deleted file mode 100644 index bc5e0d2..0000000 --- a/rails_5.2.gemfile +++ /dev/null @@ -1,15 +0,0 @@ -source 'https://rubygems.org' - -# Specify your gem's dependencies in active_record_union.gemspec -gemspec - -gem 'rails', '~> 5.2.0' - -# https://github.com/rails/rails/blob/v5.2.2/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L4 -gem "pg", ">= 0.18", "< 2.0" - -# https://github.com/rails/rails/blob/v5.2.2/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L13 -gem 'sqlite3', '~> 1.3.6' - -# https://github.com/rails/rails/blob/v5.2.2/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb#L6 -gem "mysql2", ">= 0.4.4", "< 0.6.0"