summaryrefslogtreecommitdiff
path: root/config/initializers/nulls_last.rb
blob: 47b7b0bb3d23739bc5f3062ff1590dfcc2d07efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module ActiveRecord
  class Base
    def self.nulls_last(field, direction = 'ASC')
      if Gitlab::Database.postgresql?
        "#{field} #{direction} NULLS LAST"
      else
        if direction.upcase == 'ASC'
          "-#{field} DESC"
        else
          "#{field} DESC"
        end
      end
    end
  end
end