server/sources/rql2sql.py
changeset 1122 9f37de24251f
parent 438 69b79faefa94
child 1124 5548b608b7d9
equal deleted inserted replaced
1121:43fa67acd9d0 1122:9f37de24251f
   800             if rhsconst:
   800             if rhsconst:
   801                 join += ' AND %s.%s=%s)' % (rid, restrattr, rhssql)
   801                 join += ' AND %s.%s=%s)' % (rid, restrattr, rhssql)
   802             else:
   802             else:
   803                 join += ')'
   803                 join += ')'
   804         if not rhsconst:
   804         if not rhsconst:
   805             rhstable = self._var_table(rhsvar)
   805             rhstable = rhsvar._q_sqltable
   806             if rhstable:
   806             if rhstable:
   807                 assert rhstable is not None, rhsvar
   807                 assert rhstable is not None, rhsvar
   808                 join += ' %s OUTER JOIN %s ON (%s.%s=%s)' % (
   808                 join += ' %s OUTER JOIN %s ON (%s.%s=%s)' % (
   809                     outertype, self._state.tables[rhstable][1], rid, restrattr, rhssql)
   809                     outertype, self._state.tables[rhstable][1], rid, restrattr, rhssql)
   810                 toreplace.append(rhstable)
   810                 toreplace.append(rhstable)
   965 
   965 
   966     def visit_columnalias(self, colalias, contextrels=None):
   966     def visit_columnalias(self, colalias, contextrels=None):
   967         """get the sql name for a subquery column alias"""
   967         """get the sql name for a subquery column alias"""
   968         if colalias.name in self._varmap:
   968         if colalias.name in self._varmap:
   969             sql = self._varmap[colalias.name]
   969             sql = self._varmap[colalias.name]
   970             self.add_table(sql.split('.', 1)[0])
   970             table = sql.split('.', 1)[0]
       
   971             colalias._q_sqltable = table
       
   972             colalias._q_sql = sql
       
   973             self.add_table(table)
   971             return sql
   974             return sql
   972         return colalias._q_sql
   975         return colalias._q_sql
   973     
   976     
   974     def visit_variable(self, variable, contextrels=None):
   977     def visit_variable(self, variable, contextrels=None):
   975         """get the table name and sql string for a variable"""
   978         """get the table name and sql string for a variable"""