[rset] Fix regression with rset copying (closes #3344410) stable
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 03 Dec 2013 13:23:59 +0100
branchstable
changeset 9331 c6f54ed6b60a
parent 9330 45e0034e2a73
child 9332 7a5d46db5c36
[rset] Fix regression with rset copying (closes #3344410) Don't override passed-in descriptions in ResultSet.__init__, even if they're empty.
rset.py
server/test/unittest_querier.py
test/unittest_rset.py
--- a/rset.py	Wed Dec 04 14:26:35 2013 +0100
+++ b/rset.py	Tue Dec 03 13:23:59 2013 +0100
@@ -53,7 +53,10 @@
         self.args = args
         # entity types for each cell (same shape as rows)
         # maybe discarded if specified when the query has been executed
-        self.description = description or []
+        if description is None:
+            self.description = []
+        else:
+            self.description = description
         # parsed syntax tree
         if rqlst is not None:
             rqlst.schema = None # reset schema in case of pyro transfert
--- a/server/test/unittest_querier.py	Wed Dec 04 14:26:35 2013 +0100
+++ b/server/test/unittest_querier.py	Tue Dec 03 13:23:59 2013 +0100
@@ -702,7 +702,7 @@
         rset = self.execute('Any X WHERE X is CWGroup', build_descr=0)
         rset.rows.sort()
         self.assertEqual(tuplify(rset.rows), [(2,), (3,), (4,), (5,)])
-        self.assertEqual(rset.description, [])
+        self.assertEqual(rset.description, ())
 
     def test_select_limit_offset(self):
         rset = self.execute('CWGroup X ORDERBY N LIMIT 2 WHERE X name N')
--- a/test/unittest_rset.py	Wed Dec 04 14:26:35 2013 +0100
+++ b/test/unittest_rset.py	Tue Dec 03 13:23:59 2013 +0100
@@ -181,6 +181,7 @@
         rs2 = rs.filtered_rset(test_filter)
         self.assertEqual(len(rs2), 2)
         self.assertEqual([login for _, login in rs2], ['adim', 'syt'])
+        self.assertEqual(rs2.description, rs.description[1:])
 
     def test_transform(self):
         rs = ResultSet([[12, 'adim'], [13, 'syt'], [14, 'nico']],