Skip to content

Commit

Permalink
Prefer feature detection over version comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
nertzy committed Aug 11, 2024
1 parent 9391e7e commit c3594b9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pg_search/scope_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ def subquery
.offset(nil)
end

AREL_OR_NODE_ARITY = Arel::Nodes::Or.instance_method(:initialize).arity

def conditions
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")
if AREL_OR_NODE_ARITY == 1
Arel::Nodes::Or.new(expressions)
else
expressions.inject { |accumulator, expression| Arel::Nodes::Or.new(accumulator, expression) }
Expand Down

0 comments on commit c3594b9

Please sign in to comment.