Commit b21dcb36 authored by Adam Hegyi's avatar Adam Hegyi

Fix SimpleOrderBuilder undefined method error

This change fixes the undefined method error when an AR scope is passed
with complex arel expression (CASE).
parent 21607dbf
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Pagination::Keyset::SimpleOrderBuilder do
context 'when ordering by a CASE expression and id' do
let(:scope) { Vulnerability.order_report_type_asc }
subject(:result) { described_class.build(scope) }
it 'does not raise error' do
expect { result }.not_to raise_error
end
it 'does not support this ordering' do
_, success = result
expect(success).to eq(false)
end
end
end
......@@ -122,6 +122,7 @@ module Gitlab
return unless attribute
return unless tie_breaker_attribute
return unless attribute.respond_to?(:name)
model_class.column_names.include?(attribute.name.to_s) &&
arel_table[primary_key].to_s == tie_breaker_attribute.to_s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment