[rql2sql] test and fix a bug triggered when editing a ticket in jpl stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 19 Aug 2009 00:00:34 +0200
branchstable
changeset 2915 651bbe1526b6
parent 2914 03fe782c6500
child 2916 f42029293e59
[rql2sql] test and fix a bug triggered when editing a ticket in jpl
server/sources/rql2sql.py
server/test/unittest_rql2sql.py
--- a/server/sources/rql2sql.py	Tue Aug 18 23:29:26 2009 +0200
+++ b/server/sources/rql2sql.py	Wed Aug 19 00:00:34 2009 +0200
@@ -1146,7 +1146,9 @@
             key = table
         if key in self._state.tables:
             return
-        self._state.tables[key] = (len(self._state.actual_tables) - 1, table)
+        if scope == -1:
+            scope = len(self._state.actual_tables) - 1
+        self._state.tables[key] = (scope, table)
         self._state.actual_tables[scope].append(table)
 
     def replace_tables_by_outer_join(self, substitute, lefttable, *tables):
--- a/server/test/unittest_rql2sql.py	Tue Aug 18 23:29:26 2009 +0200
+++ b/server/test/unittest_rql2sql.py	Wed Aug 19 00:00:34 2009 +0200
@@ -888,6 +888,10 @@
 SELECT G.cw_eid AS C0, S.cw_eid AS C1
 FROM cw_Note AS G LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop) ) AS _T0 ON (rel_tags0.eid_to=_T0.C0)'''),
 
+    ('Any O,AD  WHERE NOT S inline1 O, S eid 123, O todo_by AD?',
+     '''SELECT O.cw_eid, rel_todo_by0.eid_to
+FROM cw_Affaire AS O LEFT OUTER JOIN todo_by_relation AS rel_todo_by0 ON (rel_todo_by0.eid_from=O.cw_eid), cw_Note AS S
+WHERE NOT EXISTS(SELECT 1 WHERE S.cw_inline1=O.cw_eid) AND S.cw_eid=123''')
     ]
 
 VIRTUAL_VARS = [