diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/nulls_last.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/config/initializers/nulls_last.rb b/config/initializers/nulls_last.rb new file mode 100644 index 00000000000..47b7b0bb3d2 --- /dev/null +++ b/config/initializers/nulls_last.rb @@ -0,0 +1,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 |