diff options
author | Thijs Wouters <thijs@morewood.be> | 2016-03-14 10:46:26 +0100 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-06-06 11:59:49 -0500 |
commit | d8263b285193d9163089683eb77825f1cd673b14 (patch) | |
tree | 4ecdabc6af9a09556fdb212488d381b43d20ae10 /config | |
parent | 0e2f26dd2a10ed876f96b0496dff2de6780eeaea (diff) | |
download | gitlab-ce-d8263b285193d9163089683eb77825f1cd673b14.tar.gz |
Sort by label priority
Signed-off-by: Rémy Coutable <remy@rymai.me>
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 |