diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 882b32fa..a22f2415 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,6 @@ jobs: matrix: ruby-version: ["3.3", "3.4", "4.0"] active-record: - - { label: "7.2", env: "ACTIVE_RECORD_VERSION=~> 7.2.0" } - { label: "8.0", env: "ACTIVE_RECORD_VERSION=~> 8.0.0" } - { label: "8.1", env: "ACTIVE_RECORD_VERSION=~> 8.1.0" } allow-failure: [false] @@ -60,9 +59,6 @@ jobs: - ruby-version: "4.0" active-record: { label: "8-0-stable", env: "ACTIVE_RECORD_BRANCH=8-0-stable" } allow-failure: true - - ruby-version: "4.0" - active-record: { label: "7-2-stable", env: "ACTIVE_RECORD_BRANCH=7-2-stable" } - allow-failure: true - ruby-version: "ruby-head" active-record: { label: "8.1", env: "ACTIVE_RECORD_VERSION=~> 8.1.0" } allow-failure: true diff --git a/.standard.yml b/.standard.yml index e6a88f37..a6648c8c 100644 --- a/.standard.yml +++ b/.standard.yml @@ -3,4 +3,4 @@ ruby_version: 3.3 plugins: - standard-performance - standard-rails: - target_rails_version: 7.2 + target_rails_version: 8.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index ef594cee..8e6842f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # pg_search changelog +## Unreleased + +* Drop support for Active Record 7.2 + ## 2.3.8 * Drop support for Ruby 3.0, 3.1, and 3.2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37c8e217..01883663 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ Don't be discouraged if the maintainers ask you to change your code. We are alwa Our automated tests start by updating all gems to their latest version. This is by design, because we want to be proactive about compatibility with other libraries. You can do the same by running `bundle update` at any time. To test against a specific version of Active Record, you can set the `ACTIVE_RECORD_VERSION` environment variable. - $ ACTIVE_RECORD_VERSION=5.0 bundle update + $ ACTIVE_RECORD_VERSION="~> 8.0.0" bundle update Run the tests by running `bundle exec rake`, or `bin/rake` if you use Bundler binstubs. diff --git a/README.md b/README.md index a7b71828..d944e907 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Read the blog post introducing PgSearch at https://tanzu.vmware.com/content/blog ## REQUIREMENTS - Ruby 3.3+ -- Active Record 7.2+ +- Active Record 8.0+ - PostgreSQL 9.2+ - [PostgreSQL extensions](https://github.com/Casecommons/pg_search/wiki/Installing-PostgreSQL-Extensions) for certain features diff --git a/lib/pg_search/migration/generator.rb b/lib/pg_search/migration/generator.rb index 2cf06a46..18e909b6 100644 --- a/lib/pg_search/migration/generator.rb +++ b/lib/pg_search/migration/generator.rb @@ -28,11 +28,7 @@ def read_sql_file(filename) end def migration_version - if ActiveRecord::VERSION::MAJOR >= 5 - "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" - else - "" - end + "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end end end diff --git a/lib/pg_search/scope_options.rb b/lib/pg_search/scope_options.rb index a4d2397d..6bfd0d6d 100644 --- a/lib/pg_search/scope_options.rb +++ b/lib/pg_search/scope_options.rb @@ -96,28 +96,9 @@ def conditions .reject { |_feature_name, feature_options| feature_options && feature_options[:sort_only] } .map { |feature_name, _feature_options| feature_for(feature_name).conditions } - or_node(expressions) + Arel::Nodes::Or.new(expressions) end - # https://github.com/rails/rails/pull/51492 - # :nocov: - # standard:disable Lint/DuplicateMethods - or_arity = Arel::Nodes::Or.instance_method(:initialize).arity - case or_arity - when 1 - def or_node(expressions) - Arel::Nodes::Or.new(expressions) - end - when 2 - def or_node(expressions) - expressions.inject { |accumulator, expression| Arel::Nodes::Or.new(accumulator, expression) } - end - else - raise "Unsupported arity #{or_arity} for Arel::Nodes::Or#initialize" - end - # :nocov: - # standard:enable Lint/DuplicateMethods - def order_within_rank config.order_within_rank || "#{primary_key} ASC" end diff --git a/pg_search.gemspec b/pg_search.gemspec index 7967d121..179796f2 100644 --- a/pg_search.gemspec +++ b/pg_search.gemspec @@ -18,8 +18,8 @@ Gem::Specification.new do |s| s.files = `git ls-files -z`.split("\x0") s.require_paths = ["lib"] - s.add_dependency "activerecord", ">= 7.2" - s.add_dependency "activesupport", ">= 7.2" + s.add_dependency "activerecord", ">= 8.0" + s.add_dependency "activesupport", ">= 8.0" s.required_ruby_version = ">= 3.3" end diff --git a/spec/lib/pg_search_spec.rb b/spec/lib/pg_search_spec.rb index f58f1ac1..0e063023 100644 --- a/spec/lib/pg_search_spec.rb +++ b/spec/lib/pg_search_spec.rb @@ -2,17 +2,6 @@ require "spec_helper" -# For Active Record 5.x, the association reflection's cache needs be cleared -# because we're stubbing the related constants. -if ActiveRecord::VERSION::MAJOR == 5 - def clear_searchable_cache - PgSearch::Document.reflect_on_association(:searchable).clear_association_scope_cache - end -else - def clear_searchable_cache - end -end - # standard:disable RSpec/NestedGroups describe PgSearch do describe ".multisearch" do @@ -32,10 +21,7 @@ def clear_searchable_cache end context "with PgSearch.multisearch_options set to a Hash" do - subject do - clear_searchable_cache - described_class.multisearch(query).map(&:searchable) - end + subject { described_class.multisearch(query).map(&:searchable) } before { allow(described_class).to receive(:multisearch_options).and_return(using: :dmetaphone) } @@ -57,10 +43,7 @@ def clear_searchable_cache end context "with PgSearch.multisearch_options set to a Proc" do - subject do - clear_searchable_cache - described_class.multisearch(query, soundalike).map(&:searchable) - end + subject { described_class.multisearch(query, soundalike).map(&:searchable) } before do allow(described_class).to receive(:multisearch_options) do @@ -169,7 +152,6 @@ def clear_searchable_cache PgSearch::Multisearch.rebuild(SearchableSubclassModel) - clear_searchable_cache expect(PgSearch::Document.count).to be 1 expect(PgSearch::Document.first.searchable.class).to be SearchableSubclassModel expect(PgSearch::Document.first.searchable).to eq expected @@ -184,7 +166,6 @@ def clear_searchable_cache PgSearch::Multisearch.rebuild(SearchableSubclassModel) expect(PgSearch::Document.count).to be 2 - clear_searchable_cache classes = PgSearch::Document.all.collect { |d| d.searchable.class } expect(classes).to include SearchableSubclassModel expect(classes).to include AnotherSearchableSubclassModel