1175 # no principal defined, relation is necessarily the principal and |
1175 # no principal defined, relation is necessarily the principal and |
1176 # so nothing to return here |
1176 # so nothing to return here |
1177 pass |
1177 pass |
1178 return '' |
1178 return '' |
1179 |
1179 |
|
1180 def _temp_table_scope(self, select, table): |
|
1181 scope = 9999 |
|
1182 for var, sql in self._varmap.iteritems(): |
|
1183 if table == sql.split('.', 1)[0]: |
|
1184 try: |
|
1185 scope = min(scope, self._state.scopes[select.defined_vars[var].scope]) |
|
1186 except KeyError: |
|
1187 scope = 0 # XXX |
|
1188 if scope == 0: |
|
1189 return 0 |
|
1190 return 0 |
|
1191 |
1180 def _var_info(self, var): |
1192 def _var_info(self, var): |
1181 scope = self._state.scopes[var.scope] |
|
1182 try: |
1193 try: |
1183 sql = self._varmap[var.name] |
1194 sql = self._varmap[var.name] |
1184 tablealias = sql.split('.', 1)[0] |
1195 tablealias = sql.split('.', 1)[0] |
|
1196 scope = self._temp_table_scope(var.stmt, tablealias) |
1185 self.add_table(tablealias, scope=scope) |
1197 self.add_table(tablealias, scope=scope) |
1186 except KeyError: |
1198 except KeyError: |
|
1199 scope = self._state.scopes[var.scope] |
1187 etype = self._state.solution[var.name] |
1200 etype = self._state.solution[var.name] |
1188 # XXX this check should be moved in rql.stcheck |
1201 # XXX this check should be moved in rql.stcheck |
1189 if self.schema.eschema(etype).final: |
1202 if self.schema.eschema(etype).final: |
1190 raise BadRQLQuery(var.stmt.root) |
1203 raise BadRQLQuery(var.stmt.root) |
1191 tablealias = '_' + var.name |
1204 tablealias = '_' + var.name |