--- 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
--- a/server/test/unittest_rql2sql.py Thu Oct 14 10:15:56 2010 +0200
+++ b/server/test/unittest_rql2sql.py Thu Oct 14 14:10:02 2010 +0200
@@ -570,8 +570,6 @@
('Any 1 WHERE X in_group G, X is CWUser',
'''SELECT 1
FROM in_group_relation AS rel_in_group0'''),
-
-
]
@@ -1415,6 +1413,13 @@
FROM appears AS appears0
WHERE appears0.words @@ to_tsquery('default', 'toto&tata')"""),
+
+ ('Any X WHERE NOT A tags X, X has_text "pouet"',
+ '''SELECT appears1.uid
+FROM appears AS appears1
+WHERE NOT (EXISTS(SELECT 1 FROM tags_relation AS rel_tags0 WHERE appears1.uid=rel_tags0.eid_to)) AND appears1.words @@ to_tsquery('default', 'pouet')
+'''),
+
)):
yield t