# HG changeset patch # User Sylvain Thénault # Date 1251286023 -7200 # Node ID 5787d1cc810627dc169e4880f536c7ce3575fc5f # Parent 0588e39f67439e002af869c4db98321f914ac893 [rset] fix #231354 w/ rql 0.22.3 api diff -r 0588e39f6743 -r 5787d1cc8106 debian/control --- a/debian/control Wed Aug 26 11:16:10 2009 +0200 +++ b/debian/control Wed Aug 26 13:27:03 2009 +0200 @@ -76,7 +76,7 @@ Package: cubicweb-common Architecture: all XB-Python-Version: ${python:Versions} -Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.6.0), python-logilab-common (>= 0.44.0), python-yams (>= 0.24.0), python-rql (>= 0.22.1), python-lxml +Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.6.0), python-logilab-common (>= 0.44.0), python-yams (>= 0.24.0), python-rql (>= 0.22.3), python-lxml Recommends: python-simpletal (>= 4.0) Conflicts: cubicweb-core Replaces: cubicweb-core diff -r 0588e39f6743 -r 5787d1cc8106 rset.py --- a/rset.py Wed Aug 26 11:16:10 2009 +0200 +++ b/rset.py Wed Aug 26 13:27:03 2009 +0200 @@ -395,7 +395,7 @@ if rqlst.TYPE == 'select': # UNION query, find the subquery from which this entity has been # found - rqlst = rqlst.locate_subquery(col, etype, self.args) + rqlst, col = rqlst.locate_subquery(col, etype, self.args) # take care, due to outer join support, we may find None # values for non final relation for i, attr, x in attr_desc_iterator(rqlst, col): @@ -495,7 +495,8 @@ if len(self.column_types(i)) > 1: break # UNION query, find the subquery from which this entity has been found - select = rqlst.locate_subquery(locate_query_col, etype, self.args) + select = rqlst.locate_subquery(locate_query_col, etype, self.args)[0] + col = rqlst.subquery_selection_index(select, col) try: myvar = select.selection[col].variable except AttributeError: @@ -503,7 +504,7 @@ return None, None rel = myvar.main_relation() if rel is not None: - index = rel.children[0].variable.selected_index() + index = rel.children[0].root_selection_index() if index is not None and self.rows[row][index]: return self.get_entity(row, index), rel.r_type return None, None diff -r 0588e39f6743 -r 5787d1cc8106 server/sources/pyrorql.py --- a/server/sources/pyrorql.py Wed Aug 26 11:16:10 2009 +0200 +++ b/server/sources/pyrorql.py Wed Aug 26 13:27:03 2009 +0200 @@ -26,6 +26,12 @@ from cubicweb.server.sources import (AbstractSource, ConnectionWrapper, TimedCache, dbg_st_search, dbg_results) + +def uidtype(union, col, etype, args): + select, col = union.locate_subquery(col, etype, args) + return getattr(select.selection[col], 'uidtype', None) + + class ReplaceByInOperator(Exception): def __init__(self, eids): self.eids = eids @@ -295,8 +301,8 @@ needtranslation = [] rows = rset.rows for i, etype in enumerate(descr[0]): - if (etype is None or not self.schema.eschema(etype).is_final() or - getattr(union.locate_subquery(i, etype, args).selection[i], 'uidtype', None)): + if (etype is None or not self.schema.eschema(etype).is_final() + or uidtype(union, i, etype, args)): needtranslation.append(i) if needtranslation: cnx = session.pool.connection(self.uri) diff -r 0588e39f6743 -r 5787d1cc8106 test/unittest_rset.py --- a/test/unittest_rset.py Wed Aug 26 11:16:10 2009 +0200 +++ b/test/unittest_rset.py Wed Aug 26 13:27:03 2009 +0200 @@ -328,6 +328,7 @@ entity, rtype = rset.related_entity(1, 1) self.assertEquals(entity.id, 'CWGroup') self.assertEquals(rtype, 'name') + # rset = self.execute('Any X,N ORDERBY N WHERE X is Bookmark WITH X,N BEING ' '((Any X,N WHERE X is CWGroup, X name N)' ' UNION ' @@ -335,6 +336,14 @@ entity, rtype = rset.related_entity(0, 1) self.assertEquals(entity.eid, e.eid) self.assertEquals(rtype, 'title') + # + rset = self.execute('Any X,N ORDERBY N WITH N,X BEING ' + '((Any N,X WHERE X is CWGroup, X name N)' + ' UNION ' + ' (Any N,X WHERE X is Bookmark, X title N))') + entity, rtype = rset.related_entity(0, 1) + self.assertEquals(entity.eid, e.eid) + self.assertEquals(rtype, 'title') def test_entities(self): rset = self.execute('Any U,G WHERE U in_group G')