server/sources/rql2sql.py
changeset 6493 019ab5eb37ea
parent 6491 ee9a10b6620e
child 6929 e9464d975908
--- a/server/sources/rql2sql.py	Thu Oct 14 10:15:56 2010 +0200
+++ b/server/sources/rql2sql.py	Thu Oct 14 14:10:02 2010 +0200
@@ -1337,10 +1337,10 @@
 
     # tables handling #########################################################
 
-    def alias_and_add_table(self, tablename):
+    def alias_and_add_table(self, tablename, scope=-1):
         alias = '%s%s' % (tablename, self._state.count)
         self._state.count += 1
-        self.add_table('%s AS %s' % (tablename, alias), alias)
+        self.add_table('%s AS %s' % (tablename, alias), alias, scope)
         return alias
 
     def add_table(self, table, key=None, scope=-1):
@@ -1437,6 +1437,7 @@
             except AttributeError:
                 pass
         self._state.done.add(relation)
-        alias = self.alias_and_add_table(self.dbhelper.fti_table)
+        scope = self._state.scopes[relation.scope]
+        alias = self.alias_and_add_table(self.dbhelper.fti_table, scope=scope)
         relation._q_sqltable = alias
         return alias