[selectors] EClassSelector (eg is_instance & all) should check for None value (possible w/ outer join) when a row is specified. Closes #2033165 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Oct 2011 10:59:57 +0200
branchstable
changeset 7982 77ed9b2fc9a5
parent 7978 b6150210f692
child 7983 07afe32945aa
[selectors] EClassSelector (eg is_instance & all) should check for None value (possible w/ outer join) when a row is specified. Closes #2033165
selectors.py
test/unittest_selectors.py
--- a/selectors.py	Fri Oct 21 09:23:43 2011 +0200
+++ b/selectors.py	Fri Oct 21 10:59:57 2011 +0200
@@ -303,7 +303,7 @@
         else:
             etype = rset.description[row][col]
             # may have None in rset.description on outer join
-            if etype is None:
+            if etype is None or rset.rows[row][col] is None:
                 return 0
             etypes = (etype,)
         score = 0
--- a/test/unittest_selectors.py	Fri Oct 21 09:23:43 2011 +0200
+++ b/test/unittest_selectors.py	Fri Oct 21 10:59:57 2011 +0200
@@ -164,6 +164,12 @@
         self.assertEqual(is_instance('BaseTransition').score_class(cls, self.request()),
                           3)
 
+    def test_outer_join(self):
+        req = self.request()
+        rset = req.execute('Any U,B WHERE B? bookmarked_by U, U login "anon"')
+        self.assertEqual(is_instance('Bookmark')(None, req, rset=rset, row=0, col=1),
+                         0)
+
 
 class WorkflowSelectorTC(CubicWebTC):
     def _commit(self):