From 411b3703fdeb3e80fcd15a2ff9eb9ac85406d4b3 Mon Sep 17 00:00:00 2001 From: Marta Noya Date: Tue, 10 Sep 2019 11:32:51 +0200 Subject: [PATCH] [Bugfix][Oracle] path order in routing_policy working for null/empty values --- app/lib/backend_api_logic/routing_policy.rb | 4 ++-- app/models/backend_api_config.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/lib/backend_api_logic/routing_policy.rb b/app/lib/backend_api_logic/routing_policy.rb index b9bfbba063..5eeadb1fd4 100644 --- a/app/lib/backend_api_logic/routing_policy.rb +++ b/app/lib/backend_api_logic/routing_policy.rb @@ -17,7 +17,7 @@ def initialize(service) end def to_a - rules = backend_api_configs.reorder(path: :desc).each_with_object([]) do |config, rules| + rules = backend_api_configs.reordering { sift(:path_desc) }.each_with_object([]) do |config, rules| rule = Rule.new(config).as_json rules << rule if rule end @@ -54,7 +54,7 @@ def as_json end def path_to_regex - if path.empty? + if path.to_s.empty? "/.*" else "/#{path}/.*|/#{path}/?" diff --git a/app/models/backend_api_config.rb b/app/models/backend_api_config.rb index 60d0409265..4a9a4affa9 100644 --- a/app/models/backend_api_config.rb +++ b/app/models/backend_api_config.rb @@ -14,6 +14,10 @@ class BackendApiConfig < ApplicationRecord backend_api.metrics.each { |metric| metric.send(:sync_backend) } end + sifter :path_desc do + System::Database.oracle? ? 'path DESC NULLS LAST' : {path: :desc} + end + delegate :private_endpoint, to: :backend_api def path=(value)