Skip to content

Commit

Permalink
Use ActiveRecord version-dependent inspect method
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine-Gerard authored and glebm committed Oct 11, 2024
1 parent b407f24 commit 4a81138
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/order_query/point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def value(column)
v = record.send(column.name)
if v.nil? && !column.nullable?
fail Errors::NonNullableColumnIsNullError,
"Column #{column.inspect} is NULL on record #{@record.full_inspect}. "\
"Column #{column.inspect} is NULL on record #{@record.send(inspect_method)}. "\
'Set the `nulls` option to :first or :last.'
end
v
end

def inspect
"#<OrderQuery::Point @record=#{@record.full_inspect} @space=#{@space.inspect}>"
"#<OrderQuery::Point @record=#{@record.send(inspect_method)} @space=#{@space.inspect}>"
end

protected
Expand All @@ -85,5 +85,11 @@ def inspect
def unless_record_eq(rec)
rec unless rec == @record
end

private
def inspect_method
Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("7.2.0") ? :full_inspect
: :inspect
end
end
end

0 comments on commit 4a81138

Please sign in to comment.