Skip to content

Commit

Permalink
Fix compatibility with ActiveRecord 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Jul 1, 2024
1 parent 2e70205 commit 9391e7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ jobs:
- ACTIVE_RECORD_VERSION="~> 6.1.0"
- ACTIVE_RECORD_VERSION="~> 7.0.0"
- ACTIVE_RECORD_VERSION="~> 7.1.0"
- ACTIVE_RECORD_VERSION="~> 7.2.0.beta2"
allow-failure: [false]
include:
- ruby-version: '3.3'
active-record-version-env: ACTIVE_RECORD_BRANCH="main"
allow-failure: true
- ruby-version: '3.3'
active-record-version-env: ACTIVE_RECORD_BRANCH="7-2-stable"
allow-failure: true
- ruby-version: '3.3'
active-record-version-env: ACTIVE_RECORD_BRANCH="7-1-stable"
allow-failure: true
Expand Down
15 changes: 11 additions & 4 deletions lib/pg_search/scope_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@ def subquery
end

def conditions
config.features
.reject { |_feature_name, feature_options| feature_options && feature_options[:sort_only] }
.map { |feature_name, _feature_options| feature_for(feature_name).conditions }
.inject { |accumulator, expression| Arel::Nodes::Or.new(accumulator, expression) }
expressions =
config.features
.reject { |_feature_name, feature_options| feature_options && feature_options[:sort_only] }
.map { |feature_name, _feature_options| feature_for(feature_name).conditions }

# https://github.com/rails/rails/pull/51492
if ActiveRecord.version >= Gem::Version.new("7.2.0.beta1")
Arel::Nodes::Or.new(expressions)
else
expressions.inject { |accumulator, expression| Arel::Nodes::Or.new(accumulator, expression) }
end
end

def order_within_rank
Expand Down

0 comments on commit 9391e7e

Please sign in to comment.