debian-mirror-gitlab/lib/gitlab/graphql/pagination/keyset/conditions/null_condition.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Gitlab
module Graphql
2020-04-22 19:07:51 +05:30
module Pagination
2019-12-26 22:10:19 +05:30
module Keyset
module Conditions
class NullCondition < BaseCondition
def build
[first_attribute_condition, final_condition].join
end
private
# ex: "(relative_position IS NULL AND id > 500)"
def first_attribute_condition
2021-04-29 21:17:54 +05:30
<<~SQL
2019-12-26 22:10:19 +05:30
(
2020-03-13 15:44:24 +05:30
#{table_condition(order_list.first, nil, 'is_null').to_sql}
2019-12-26 22:10:19 +05:30
AND
2020-03-13 15:44:24 +05:30
#{table_condition(order_list[1], values[1], operators[1]).to_sql}
2019-12-26 22:10:19 +05:30
)
SQL
end
# ex: " OR (relative_position IS NOT NULL)"
def final_condition
if before_or_after == :before
<<~SQL
2020-03-13 15:44:24 +05:30
OR (#{table_condition(order_list.first, nil, 'is_not_null').to_sql})
2019-12-26 22:10:19 +05:30
SQL
end
end
end
end
end
end
end
end