--- a/rset.py Wed May 18 16:04:47 2011 +0200
+++ b/rset.py Thu May 19 10:36:26 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -79,7 +79,7 @@
rows = rows[:10] + ['...']
if len(rows) > 1:
# add a line break before first entity if more that one.
- pattern = '<resultset %r (%s rows):\n%s>'
+ pattern = '<resultset %r (%s rows):\n%s>'
else:
pattern = '<resultset %r (%s rows): %s>'
@@ -687,8 +687,12 @@
root = rootselect.parent
selectmain = select.selection[selectidx]
for i, term in enumerate(rootselect.selection):
- rootvar = _get_variable(term)
- if rootvar is None:
+ try:
+ # don't use _get_variable here: if the term isn't a variable
+ # (function...), we don't want it to be used as an entity attribute
+ # or relation's value (XXX beside MAX/MIN trick?)
+ rootvar = term.variable
+ except AttributeError:
continue
if rootvar.name == rootmainvar.name:
continue
--- a/server/test/unittest_querier.py Wed May 18 16:04:47 2011 +0200
+++ b/server/test/unittest_querier.py Thu May 19 10:36:26 2011 +0200
@@ -1452,6 +1452,13 @@
def test_nonregr_final_norestr(self):
self.assertRaises(BadRQLQuery, self.execute, 'Date X')
+ def test_nonregr_eid_cmp(self):
+ peid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
+ peid2 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
+ rset = self.execute('Any X,Y WHERE X is Personne, Y is Personne, X nom XD, Y nom XD, X eid Z, Y eid > Z')
+ self.assertEqual(rset.rows, [[peid1, peid2]])
+ rset = self.execute('Any X,Y WHERE X nom XD, Y nom XD, X eid Z, Y eid > Z')
+ self.assertEqual(rset.rows, [[peid1, peid2]])
if __name__ == '__main__':
unittest_main()
--- a/server/test/unittest_rql2sql.py Wed May 18 16:04:47 2011 +0200
+++ b/server/test/unittest_rql2sql.py Thu May 19 10:36:26 2011 +0200
@@ -631,7 +631,12 @@
("Personne X,Y where X nom NX, Y nom NX, X eid XE, not Y eid XE",
'''SELECT _X.cw_eid, _Y.cw_eid
FROM cw_Personne AS _X, cw_Personne AS _Y
-WHERE _Y.cw_nom=_X.cw_nom AND NOT (_Y.cw_eid=_X.cw_eid)''')
+WHERE _Y.cw_nom=_X.cw_nom AND NOT (_Y.cw_eid=_X.cw_eid)'''),
+
+ ('Any X,Y WHERE X is Personne, Y is Personne, X nom XD, Y nom XD, X eid Z, Y eid > Z',
+ '''SELECT _X.cw_eid, _Y.cw_eid
+FROM cw_Personne AS _X, cw_Personne AS _Y
+WHERE _Y.cw_nom=_X.cw_nom AND _Y.cw_eid>_X.cw_eid'''),
]
--- a/test/unittest_rset.py Wed May 18 16:04:47 2011 +0200
+++ b/test/unittest_rset.py Thu May 19 10:36:26 2011 +0200
@@ -1,5 +1,5 @@
# coding: utf-8
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -63,6 +63,13 @@
result = list(attr_desc_iterator(parse(rql).children[0], idx, idx))
self.assertEqual(result, relations)
+ def test_subquery_callfunc(self):
+ rql = ('Any A,B,C,COUNT(D) GROUPBY A,B,C WITH A,B,C,D BEING '
+ '(Any YEAR(CD), MONTH(CD), S, X WHERE X is CWUser, X creation_date CD, X in_state S)')
+ rqlst = parse(rql)
+ select, col = rqlst.locate_subquery(2, 'CWUser', None)
+ result = list(attr_desc_iterator(select, col, 2))
+ self.assertEqual(result, [])
class ResultSetTC(CubicWebTC):
--- a/web/views/basecontrollers.py Wed May 18 16:04:47 2011 +0200
+++ b/web/views/basecontrollers.py Thu May 19 10:36:26 2011 +0200
@@ -603,8 +603,8 @@
errors = self._cw.cnx.undo_transaction(txuuid)
if not errors:
self.redirect()
- return self._cw._('some errors occurred:') + self.view('pyvalist',
- pyvalue=errors)
+ return self._cw._('some errors occurred:') + self._cw.view(
+ 'pyvalist', pyvalue=errors)
def redirect(self):
req = self._cw
--- a/web/views/plots.py Wed May 18 16:04:47 2011 +0200
+++ b/web/views/plots.py Thu May 19 10:36:26 2011 +0200
@@ -198,7 +198,7 @@
for rowidx, (_, value) in enumerate(self.cw_rset):
if value is not None:
vid = self._guess_vid(rowidx)
- label = '%s: %s' % (self.view(vid, self.cw_rset, row=rowidx, col=0),
+ label = '%s: %s' % (self._cw.view(vid, self.cw_rset, row=rowidx, col=0),
value)
labels.append(label.encode(self._cw.encoding))
values.append(value)
--- a/web/views/sparql.py Wed May 18 16:04:47 2011 +0200
+++ b/web/views/sparql.py Thu May 19 10:36:26 2011 +0200
@@ -123,7 +123,7 @@
def cell_binding(self, row, col, varname):
celltype = self.cw_rset.description[row][col]
if self._cw.vreg.schema.eschema(celltype).final:
- cellcontent = self.view('cell', self.cw_rset, row=row, col=col)
+ cellcontent = self._cw.view('cell', self.cw_rset, row=row, col=col)
return E.binding(E.literal(cellcontent,
datatype=xmlschema(celltype)),
name=varname)