# HG changeset patch # User Denis Laxalde # Date 1529392420 -7200 # Node ID 58f05ffafeca7e53aa94f0bf711763973cdee778 # Parent e947954e0ffc53f18df2d48b9ae36394b9502ae4# Parent 034bca253b551751779c97acde57caa37e1e6ed2 Merge with 3.26 diff -r e947954e0ffc -r 58f05ffafeca .hgtags --- a/.hgtags Fri Jun 15 17:45:26 2018 +0200 +++ b/.hgtags Tue Jun 19 09:13:40 2018 +0200 @@ -625,3 +625,5 @@ 9bee3134d304f6cc51ab728b4ca84d464d1b3fd8 debian/3.26.2-1 f7067be5f69cd05f34ce99fbb534e4674b3a782d 3.26.3 f7067be5f69cd05f34ce99fbb534e4674b3a782d debian/3.26.3-1 +e1c1af68db86356e7893d7f808dcb76c87623b18 3.26.4 +e1c1af68db86356e7893d7f808dcb76c87623b18 debian/3.26.4-1 diff -r e947954e0ffc -r 58f05ffafeca cubicweb.spec --- a/cubicweb.spec Fri Jun 15 17:45:26 2018 +0200 +++ b/cubicweb.spec Tue Jun 19 09:13:40 2018 +0200 @@ -8,7 +8,7 @@ %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} Name: cubicweb -Version: 3.26.3 +Version: 3.26.4 Release: logilab.1%{?dist} Summary: CubicWeb is a semantic web application framework Source0: https://pypi.python.org/packages/source/c/cubicweb/cubicweb-%{version}.tar.gz diff -r e947954e0ffc -r 58f05ffafeca cubicweb/__pkginfo__.py diff -r e947954e0ffc -r 58f05ffafeca cubicweb/server/sources/rql2sql.py --- a/cubicweb/server/sources/rql2sql.py Fri Jun 15 17:45:26 2018 +0200 +++ b/cubicweb/server/sources/rql2sql.py Tue Jun 19 09:13:40 2018 +0200 @@ -279,6 +279,14 @@ groups.append(vref) +def is_in_aggregat(node): + while node: + node = node.parent + if isinstance(node, Function) and node.descr().aggregat: + return True + return False + + def fix_selection_and_group(rqlst, needwrap, selectsortterms, sorts, groups, having): if selectsortterms and sorts: @@ -288,13 +296,11 @@ # when a query is grouped, ensure sort terms are grouped as well for sortterm in sorts: term = sortterm.term - if not (isinstance(term, Constant) or - (isinstance(term, Function) and - get_func_descr(term.name).aggregat)): - for vref in term.iget_nodes(VariableRef): - if not any(vref.is_equivalent(group) for group in groupvrefs): - groups.append(vref) - groupvrefs.append(vref) + for vref in term.iget_nodes(VariableRef): + if not (any(vref.is_equivalent(group) for group in groupvrefs) + or is_in_aggregat(vref)): + groups.append(vref) + groupvrefs.append(vref) if needwrap and (groups or having): selectedidx = set(vref.name for term in rqlst.selection for vref in term.get_nodes(VariableRef)) diff -r e947954e0ffc -r 58f05ffafeca cubicweb/server/test/unittest_rql2sql.py --- a/cubicweb/server/test/unittest_rql2sql.py Fri Jun 15 17:45:26 2018 +0200 +++ b/cubicweb/server/test/unittest_rql2sql.py Tue Jun 19 09:13:40 2018 +0200 @@ -1437,6 +1437,16 @@ WHERE _X.cw_login ~ [0-9].* ''') + def test_aggregate_in_orderby(self): + self._check("Any X GROUPBY X ORDERBY ABS(COUNT(Y)) WHERE" + "X is CWGROUP, Y is CWUSER, Y in_group X", + '''SELECT rel_in_group1.eid_to +FROM in_group_relation AS rel_in_group1, is_relation AS rel_is0, is_relation AS rel_is2 +WHERE rel_in_group1.eid_to=rel_is0.eid_from AND rel_in_group1.eid_from=rel_is2.eid_from +GROUP BY rel_in_group1.eid_to +ORDER BY ABS(COUNT(rel_in_group1.eid_from)) +''') + def test_parser_parse(self): for rql, sql in PARSER: with self.subTest(rql=rql): diff -r e947954e0ffc -r 58f05ffafeca cubicweb/utils.py diff -r e947954e0ffc -r 58f05ffafeca debian/changelog --- a/debian/changelog Fri Jun 15 17:45:26 2018 +0200 +++ b/debian/changelog Tue Jun 19 09:13:40 2018 +0200 @@ -1,3 +1,9 @@ +cubicweb (3.26.4-1) unstable; urgency=medium + + * New upstream release. + + -- Denis Laxalde Mon, 18 Jun 2018 08:58:11 +0200 + cubicweb (3.26.3-1) unstable; urgency=medium * New upstream release. diff -r e947954e0ffc -r 58f05ffafeca requirements/test-web.txt