X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a934fcf84acd4cc3a351fde1b6e21a0bd93757ef..0eb72b526bf8bbb011551ecf019f604e17a534f1:/services/api/lib/record_filters.rb diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb index c009bf537f..eb8d09b74c 100644 --- a/services/api/lib/record_filters.rb +++ b/services/api/lib/record_filters.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + # Mixin module providing a method to convert filters into a list of SQL # fragments suitable to be fed to ActiveRecord #where. # @@ -77,7 +81,12 @@ module RecordFilters "boolean attribute '#{attr}'") end end - cond_out << "#{ar_table_name}.#{attr} #{operator} ?" + if operator == '<>' + # explicitly allow NULL + cond_out << "#{ar_table_name}.#{attr} #{operator} ? OR #{ar_table_name}.#{attr} IS NULL" + else + cond_out << "#{ar_table_name}.#{attr} #{operator} ?" + end if (# any operator that operates on value rather than # representation: operator.match(/[<=>]/) and (attr_type == :datetime)) @@ -121,6 +130,8 @@ module RecordFilters end end cond_out << cond.join(' OR ') + else + raise ArgumentError.new("Invalid operator '#{operator}'") end end conds_out << cond_out.join(' OR ') if cond_out.any?