From fb5491f94ace7bbba4666a0a2aa719acd7cbfb7b Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 30 Jan 2020 11:05:32 -0300 Subject: [PATCH] 15781: Adds support for JSONB 'contains' filter. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- services/api/lib/record_filters.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb index 994e850310..e059a6e70a 100644 --- a/services/api/lib/record_filters.rb +++ b/services/api/lib/record_filters.rb @@ -19,7 +19,7 @@ module RecordFilters # +model_class+ subclass of ActiveRecord being filtered # # Output: - # Hash with two keys: + # Hash with the following keys: # :cond_out array of SQL fragments for each filter expression # :param_out array of values for parameter substitution in cond_out # :joins array of joins: either [] or ["JOIN containers ON ..."] @@ -140,6 +140,9 @@ module RecordFilters raise ArgumentError.new("Invalid operand '#{operand}' for '#{operator}' must be true or false") end param_out << proppath + when 'contains' + cond_out << "#{attr_table_name}.#{attr} @> ?::jsonb" + param_out << SafeJSON.dump({proppath => [operand]}) else raise ArgumentError.new("Invalid operator for subproperty search '#{operator}'") end -- 2.30.2