[server/rql2sql] use VariableRef.is_equivalent explicitly instead of relying on __eq__
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 08 Sep 2015 13:43:57 +0200
changeset 10652 e3e4a8c45695
parent 10651 9ca33768473c
child 10653 42c5bd7286b7
[server/rql2sql] use VariableRef.is_equivalent explicitly instead of relying on __eq__ What we want to compare is the variable referenced by the VariableRef, we should make that explicit. Closes #6694406
server/sources/rql2sql.py
--- a/server/sources/rql2sql.py	Mon Oct 12 10:53:35 2015 +0200
+++ b/server/sources/rql2sql.py	Tue Sep 08 13:43:57 2015 +0200
@@ -259,7 +259,7 @@
             append(term)
             if groups:
                 for vref in term.iget_nodes(VariableRef):
-                    if not vref in groups:
+                    if not any(vref.is_equivalent(g) for g in groups):
                         groups.append(vref)
 
 def fix_selection_and_group(rqlst, needwrap, selectsortterms,
@@ -275,7 +275,7 @@
                     (isinstance(term, Function) and
                      get_func_descr(term.name).aggregat)):
                 for vref in term.iget_nodes(VariableRef):
-                    if not vref in groupvrefs:
+                    if not any(vref.is_equivalent(group) for group in groupvrefs):
                         groups.append(vref)
                         groupvrefs.append(vref)
     if needwrap and (groups or having):