5304: include nulls in resutls when filter operator is "!="
authorRadhika Chippada <radhika@curoverse.com>
Tue, 10 Mar 2015 18:44:50 +0000 (14:44 -0400)
committerRadhika Chippada <radhika@curoverse.com>
Tue, 10 Mar 2015 18:44:50 +0000 (14:44 -0400)
services/api/lib/record_filters.rb
services/api/test/fixtures/groups.yml
services/api/test/functional/arvados/v1/groups_controller_test.rb

index c009bf537f1966fd16326ef3bc239c7d6d623f99..350c3802fc60e606fd0dba703429ca7dc98f847e 100644 (file)
@@ -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))
index fb23c8cdf4ee80ee02aae6172825308bb18a1b12..7b4f8be6dc8d2fcaf6f5acbf36d96b339c3a3385 100644 (file)
@@ -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:
index 922612fb38cd53bb3387569b477121f537cc575a..1d7bb77725222ed98c4272308a2717edaf86b6cd 100644 (file)
@@ -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