From: Radhika Chippada Date: Tue, 10 Mar 2015 18:44:50 +0000 (-0400) Subject: 5304: include nulls in resutls when filter operator is "!=" X-Git-Tag: 1.1.0~1760^2~1 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/c68037a915e0a0680c041e0c926e49233c2823f7 5304: include nulls in resutls when filter operator is "!=" --- diff --git a/services/api/lib/record_filters.rb b/services/api/lib/record_filters.rb index c009bf537f..350c3802fc 100644 --- a/services/api/lib/record_filters.rb +++ b/services/api/lib/record_filters.rb @@ -77,7 +77,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)) diff --git a/services/api/test/fixtures/groups.yml b/services/api/test/fixtures/groups.yml index fb23c8cdf4..7b4f8be6dc 100644 --- a/services/api/test/fixtures/groups.yml +++ b/services/api/test/fixtures/groups.yml @@ -224,6 +224,17 @@ fuse_owned_project: description: Test project belonging to FUSE test user group_class: project +group_with_no_class: + uuid: zzzzz-j7d0g-groupwithnoclas + owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz + created_at: 2014-04-21 15:37:48 -0400 + modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr + modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz + modified_at: 2014-04-21 15:37:48 -0400 + updated_at: 2014-04-21 15:37:48 -0400 + name: group_with_no_class + description: This group has no class at all. So rude! + # This wouldn't pass model validation, but it enables a workbench # infinite-loop test. See #4389 project_owns_itself: diff --git a/services/api/test/functional/arvados/v1/groups_controller_test.rb b/services/api/test/functional/arvados/v1/groups_controller_test.rb index 922612fb38..1d7bb77725 100644 --- a/services/api/test/functional/arvados/v1/groups_controller_test.rb +++ b/services/api/test/functional/arvados/v1/groups_controller_test.rb @@ -41,6 +41,7 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase assert_not_includes group_uuids, groups(:aproject).uuid assert_not_includes group_uuids, groups(:asubproject).uuid assert_includes group_uuids, groups(:private).uuid + assert_includes group_uuids, groups(:group_with_no_class).uuid end test "get list of groups with bogus group_class" do