Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers/nulls_last.rb')
-rw-r--r--config/initializers/nulls_last.rb15
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