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
path: root/config
diff options
context:
space:
mode:
authorThijs Wouters <thijs@morewood.be>2016-03-14 12:46:26 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2016-06-06 19:59:49 +0300
commitd8263b285193d9163089683eb77825f1cd673b14 (patch)
tree4ecdabc6af9a09556fdb212488d381b43d20ae10 /config
parent0e2f26dd2a10ed876f96b0496dff2de6780eeaea (diff)
Sort by label priority
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'config')
-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