author | Emile Anclin <emile.anclin@logilab.fr> |
Tue, 05 May 2009 17:18:49 +0200 | |
changeset 1693 | 49075f57cf2c |
parent 1251 | af40e615dc89 |
child 1263 | 01152fffd593 |
permissions | -rw-r--r-- |
0 | 1 |
"""unit tests for module cubicweb.server.sources.rql2sql""" |
2 |
||
3 |
import sys |
|
4 |
from mx.DateTime import today |
|
5 |
||
6 |
from logilab.common.testlib import TestCase, unittest_main |
|
7 |
||
8 |
from rql import BadRQLQuery |
|
9 |
from indexer import get_indexer |
|
10 |
||
11 |
#from cubicweb.server.sources.native import remove_unused_solutions |
|
12 |
from cubicweb.server.sources.rql2sql import SQLGenerator |
|
13 |
||
14 |
from rql.utils import register_function, FunctionDescr |
|
15 |
# add a dumb registered procedure |
|
16 |
class stockproc(FunctionDescr): |
|
17 |
supported_backends = ('postgres', 'sqlite', 'mysql') |
|
18 |
try: |
|
19 |
register_function(stockproc) |
|
20 |
except AssertionError, ex: |
|
21 |
pass # already registered |
|
22 |
||
23 |
from cubicweb.devtools import TestServerConfiguration |
|
24 |
from cubicweb.devtools.repotest import RQLGeneratorTC |
|
25 |
||
26 |
config = TestServerConfiguration('data') |
|
27 |
config.bootstrap_cubes() |
|
28 |
schema = config.load_schema() |
|
29 |
schema['in_state'].inlined = True |
|
30 |
schema['comments'].inlined = False |
|
31 |
||
32 |
PARSER = [ |
|
33 |
(r"Personne P WHERE P nom 'Zig\'oto';", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
34 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
35 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
36 |
WHERE P.cw_nom=Zig\'oto'''), |
0 | 37 |
|
38 |
(r'Personne P WHERE P nom ~= "Zig\"oto%";', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
39 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
40 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
41 |
WHERE P.cw_nom ILIKE Zig"oto%'''), |
0 | 42 |
] |
43 |
||
44 |
BASIC = [ |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
45 |
|
0 | 46 |
("Any X WHERE X is Affaire", |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
47 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
48 |
FROM cw_Affaire AS X'''), |
0 | 49 |
|
50 |
("Any X WHERE X eid 0", |
|
51 |
'''SELECT 0'''), |
|
52 |
||
53 |
("Personne P", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
54 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
55 |
FROM cw_Personne AS P'''), |
0 | 56 |
|
57 |
("Personne P WHERE P test TRUE", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
58 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
59 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
60 |
WHERE P.cw_test=True'''), |
0 | 61 |
|
62 |
("Personne P WHERE P test false", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
63 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
64 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
65 |
WHERE P.cw_test=False'''), |
0 | 66 |
|
67 |
("Personne P WHERE P eid -1", |
|
68 |
'''SELECT -1'''), |
|
69 |
||
70 |
("Personne P LIMIT 20 OFFSET 10", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
71 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
72 |
FROM cw_Personne AS P |
0 | 73 |
LIMIT 20 |
74 |
OFFSET 10'''), |
|
75 |
||
76 |
("Personne P WHERE S is Societe, P travaille S, S nom 'Logilab';", |
|
77 |
'''SELECT rel_travaille0.eid_from |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
78 |
FROM cw_Societe AS S, travaille_relation AS rel_travaille0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
79 |
WHERE rel_travaille0.eid_to=S.cw_eid AND S.cw_nom=Logilab'''), |
0 | 80 |
|
81 |
("Personne P WHERE P concerne A, A concerne S, S nom 'Logilab', S is Societe;", |
|
82 |
'''SELECT rel_concerne0.eid_from |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
83 |
FROM concerne_relation AS rel_concerne0, concerne_relation AS rel_concerne1, cw_Societe AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
84 |
WHERE rel_concerne0.eid_to=rel_concerne1.eid_from AND rel_concerne1.eid_to=S.cw_eid AND S.cw_nom=Logilab'''), |
0 | 85 |
|
86 |
("Note N WHERE X evaluee N, X nom 'Logilab';", |
|
87 |
'''SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
88 |
FROM cw_Division AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
89 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom=Logilab |
0 | 90 |
UNION ALL |
91 |
SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
92 |
FROM cw_Personne AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
93 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom=Logilab |
0 | 94 |
UNION ALL |
95 |
SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
96 |
FROM cw_Societe AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
97 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom=Logilab |
0 | 98 |
UNION ALL |
99 |
SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
100 |
FROM cw_SubDivision AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
101 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom=Logilab'''), |
0 | 102 |
|
103 |
("Note N WHERE X evaluee N, X nom in ('Logilab', 'Caesium');", |
|
104 |
'''SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
105 |
FROM cw_Division AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
106 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom IN(Logilab, Caesium) |
0 | 107 |
UNION ALL |
108 |
SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
109 |
FROM cw_Personne AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
110 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom IN(Logilab, Caesium) |
0 | 111 |
UNION ALL |
112 |
SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
113 |
FROM cw_Societe AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
114 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom IN(Logilab, Caesium) |
0 | 115 |
UNION ALL |
116 |
SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
117 |
FROM cw_SubDivision AS X, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
118 |
WHERE rel_evaluee0.eid_from=X.cw_eid AND X.cw_nom IN(Logilab, Caesium)'''), |
0 | 119 |
|
120 |
("Any X WHERE X creation_date TODAY, X is Affaire", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
121 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
122 |
FROM cw_Affaire AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
123 |
WHERE DATE(X.cw_creation_date)=CURRENT_DATE'''), |
0 | 124 |
|
125 |
("Any N WHERE G is EGroup, G name N, E eid 12, E read_permission G", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
126 |
'''SELECT G.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
127 |
FROM cw_EGroup AS G, read_permission_relation AS rel_read_permission0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
128 |
WHERE rel_read_permission0.eid_from=12 AND rel_read_permission0.eid_to=G.cw_eid'''), |
0 | 129 |
|
130 |
('Any Y WHERE U login "admin", U login Y', # stupid but valid... |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
131 |
"""SELECT U.cw_login |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
132 |
FROM cw_EUser AS U |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
133 |
WHERE U.cw_login=admin"""), |
0 | 134 |
|
135 |
('Any T WHERE T tags X, X is State', |
|
136 |
'''SELECT rel_tags0.eid_from |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
137 |
FROM cw_State AS X, tags_relation AS rel_tags0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
138 |
WHERE rel_tags0.eid_to=X.cw_eid'''), |
0 | 139 |
|
140 |
('Any X,Y WHERE X eid 0, Y eid 1, X concerne Y', |
|
141 |
'''SELECT 0, 1 |
|
142 |
FROM concerne_relation AS rel_concerne0 |
|
143 |
WHERE rel_concerne0.eid_from=0 AND rel_concerne0.eid_to=1'''), |
|
144 |
||
145 |
("Any X WHERE X prenom 'lulu'," |
|
146 |
"EXISTS(X owned_by U, U in_group G, G name 'lulufanclub' OR G name 'managers');", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
147 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
148 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
149 |
WHERE X.cw_prenom=lulu AND EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, in_group_relation AS rel_in_group1, cw_EGroup AS G WHERE rel_owned_by0.eid_from=X.cw_eid AND rel_in_group1.eid_from=rel_owned_by0.eid_to AND rel_in_group1.eid_to=G.cw_eid AND ((G.cw_name=lulufanclub) OR (G.cw_name=managers)))'''), |
0 | 150 |
|
151 |
("Any X WHERE X prenom 'lulu'," |
|
152 |
"NOT EXISTS(X owned_by U, U in_group G, G name 'lulufanclub' OR G name 'managers');", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
153 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
154 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
155 |
WHERE X.cw_prenom=lulu AND NOT EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, in_group_relation AS rel_in_group1, cw_EGroup AS G WHERE rel_owned_by0.eid_from=X.cw_eid AND rel_in_group1.eid_from=rel_owned_by0.eid_to AND rel_in_group1.eid_to=G.cw_eid AND ((G.cw_name=lulufanclub) OR (G.cw_name=managers)))'''), |
0 | 156 |
] |
157 |
||
158 |
ADVANCED= [ |
|
159 |
||
160 |
("Societe S WHERE S nom 'Logilab' OR S nom 'Caesium'", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
161 |
'''SELECT S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
162 |
FROM cw_Societe AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
163 |
WHERE ((S.cw_nom=Logilab) OR (S.cw_nom=Caesium))'''), |
0 | 164 |
|
165 |
('Any X WHERE X nom "toto", X eid IN (9700, 9710, 1045, 674)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
166 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
167 |
FROM cw_Division AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
168 |
WHERE X.cw_nom=toto AND X.cw_eid IN(9700, 9710, 1045, 674) |
0 | 169 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
170 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
171 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
172 |
WHERE X.cw_nom=toto AND X.cw_eid IN(9700, 9710, 1045, 674) |
0 | 173 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
174 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
175 |
FROM cw_Societe AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
176 |
WHERE X.cw_nom=toto AND X.cw_eid IN(9700, 9710, 1045, 674) |
0 | 177 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
178 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
179 |
FROM cw_SubDivision AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
180 |
WHERE X.cw_nom=toto AND X.cw_eid IN(9700, 9710, 1045, 674)'''), |
0 | 181 |
|
182 |
('Any Y, COUNT(N) GROUPBY Y WHERE Y evaluee N;', |
|
183 |
'''SELECT rel_evaluee0.eid_from, COUNT(rel_evaluee0.eid_to) |
|
184 |
FROM evaluee_relation AS rel_evaluee0 |
|
185 |
GROUP BY rel_evaluee0.eid_from'''), |
|
186 |
||
187 |
("Any X WHERE X concerne B or C concerne X", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
188 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
189 |
FROM concerne_relation AS rel_concerne0, concerne_relation AS rel_concerne1, cw_Affaire AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
190 |
WHERE ((rel_concerne0.eid_from=X.cw_eid) OR (rel_concerne1.eid_to=X.cw_eid))'''), |
0 | 191 |
|
192 |
("Any X WHERE X travaille S or X concerne A", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
193 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
194 |
FROM concerne_relation AS rel_concerne1, cw_Personne AS X, travaille_relation AS rel_travaille0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
195 |
WHERE ((rel_travaille0.eid_from=X.cw_eid) OR (rel_concerne1.eid_from=X.cw_eid))'''), |
0 | 196 |
|
197 |
("Any N WHERE A evaluee N or N ecrit_par P", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
198 |
'''SELECT N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
199 |
FROM cw_Note AS N, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
200 |
WHERE ((rel_evaluee0.eid_to=N.cw_eid) OR (N.cw_ecrit_par IS NOT NULL))'''), |
0 | 201 |
|
202 |
("Any N WHERE A evaluee N or EXISTS(N todo_by U)", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
203 |
'''SELECT N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
204 |
FROM cw_Note AS N, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
205 |
WHERE ((rel_evaluee0.eid_to=N.cw_eid) OR (EXISTS(SELECT 1 FROM todo_by_relation AS rel_todo_by1 WHERE rel_todo_by1.eid_from=N.cw_eid)))'''), |
0 | 206 |
|
207 |
("Any N WHERE A evaluee N or N todo_by U", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
208 |
'''SELECT N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
209 |
FROM cw_Note AS N, evaluee_relation AS rel_evaluee0, todo_by_relation AS rel_todo_by1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
210 |
WHERE ((rel_evaluee0.eid_to=N.cw_eid) OR (rel_todo_by1.eid_from=N.cw_eid))'''), |
0 | 211 |
|
212 |
("Any X WHERE X concerne B or C concerne X, B eid 12, C eid 13", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
213 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
214 |
FROM concerne_relation AS rel_concerne0, concerne_relation AS rel_concerne1, cw_Affaire AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
215 |
WHERE ((rel_concerne0.eid_from=X.cw_eid AND rel_concerne0.eid_to=12) OR (rel_concerne1.eid_from=13 AND rel_concerne1.eid_to=X.cw_eid))'''), |
0 | 216 |
|
217 |
('Any X WHERE X created_by U, X concerne B OR C concerne X, B eid 12, C eid 13', |
|
218 |
'''SELECT rel_created_by0.eid_from |
|
219 |
FROM concerne_relation AS rel_concerne1, concerne_relation AS rel_concerne2, created_by_relation AS rel_created_by0 |
|
220 |
WHERE ((rel_concerne1.eid_from=rel_created_by0.eid_from AND rel_concerne1.eid_to=12) OR (rel_concerne2.eid_from=13 AND rel_concerne2.eid_to=rel_created_by0.eid_from))'''), |
|
221 |
||
222 |
('Any P WHERE P travaille_subdivision S1 OR P travaille_subdivision S2, S1 nom "logilab", S2 nom "caesium"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
223 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
224 |
FROM cw_Personne AS P, cw_SubDivision AS S1, cw_SubDivision AS S2, travaille_subdivision_relation AS rel_travaille_subdivision0, travaille_subdivision_relation AS rel_travaille_subdivision1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
225 |
WHERE ((rel_travaille_subdivision0.eid_from=P.cw_eid AND rel_travaille_subdivision0.eid_to=S1.cw_eid) OR (rel_travaille_subdivision1.eid_from=P.cw_eid AND rel_travaille_subdivision1.eid_to=S2.cw_eid)) AND S1.cw_nom=logilab AND S2.cw_nom=caesium'''), |
0 | 226 |
|
227 |
('Any X WHERE T tags X', |
|
228 |
'''SELECT rel_tags0.eid_to |
|
229 |
FROM tags_relation AS rel_tags0'''), |
|
230 |
||
231 |
('Any X WHERE X in_basket B, B eid 12', |
|
232 |
'''SELECT rel_in_basket0.eid_from |
|
233 |
FROM in_basket_relation AS rel_in_basket0 |
|
234 |
WHERE rel_in_basket0.eid_to=12'''), |
|
235 |
||
236 |
('Any SEN,RN,OEN WHERE X from_entity SE, SE eid 44, X relation_type R, R eid 139, X to_entity OE, OE eid 42, R name RN, SE name SEN, OE name OEN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
237 |
'''SELECT SE.cw_name, R.cw_name, OE.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
238 |
FROM cw_EEType AS OE, cw_EEType AS SE, cw_EFRDef AS X, cw_ERType AS R |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
239 |
WHERE X.cw_from_entity=44 AND SE.cw_eid=44 AND X.cw_relation_type=139 AND R.cw_eid=139 AND X.cw_to_entity=42 AND OE.cw_eid=42 |
0 | 240 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
241 |
SELECT SE.cw_name, R.cw_name, OE.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
242 |
FROM cw_EEType AS OE, cw_EEType AS SE, cw_ENFRDef AS X, cw_ERType AS R |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
243 |
WHERE X.cw_from_entity=44 AND SE.cw_eid=44 AND X.cw_relation_type=139 AND R.cw_eid=139 AND X.cw_to_entity=42 AND OE.cw_eid=42'''), |
0 | 244 |
|
245 |
# Any O WHERE NOT S corrected_in O, S eid %(x)s, S concerns P, O version_of P, O in_state ST, NOT ST name "published", O modification_date MTIME ORDERBY MTIME DESC LIMIT 9 |
|
246 |
('Any O WHERE NOT S ecrit_par O, S eid 1, S inline1 P, O inline2 P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
247 |
'''SELECT DISTINCT O.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
248 |
FROM cw_Note AS S, cw_Personne AS O |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
249 |
WHERE (S.cw_ecrit_par IS NULL OR S.cw_ecrit_par!=O.cw_eid) AND S.cw_eid=1 AND O.cw_inline2=S.cw_inline1'''), |
0 | 250 |
|
251 |
('DISTINCT Any S ORDERBY stockproc(SI) WHERE NOT S ecrit_par O, S para SI', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
252 |
'''SELECT T1.C0 FROM (SELECT DISTINCT S.cw_eid AS C0, STOCKPROC(S.cw_para) AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
253 |
FROM cw_Note AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
254 |
WHERE S.cw_ecrit_par IS NULL |
0 | 255 |
ORDER BY 2) AS T1'''), |
256 |
||
257 |
('Any N WHERE N todo_by U, N is Note, U eid 2, N filed_under T, T eid 3', |
|
258 |
# N would actually be invarient if U eid 2 had given a specific type to U |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
259 |
'''SELECT N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
260 |
FROM cw_Note AS N, filed_under_relation AS rel_filed_under1, todo_by_relation AS rel_todo_by0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
261 |
WHERE rel_todo_by0.eid_from=N.cw_eid AND rel_todo_by0.eid_to=2 AND rel_filed_under1.eid_from=N.cw_eid AND rel_filed_under1.eid_to=3'''), |
0 | 262 |
|
263 |
('Any N WHERE N todo_by U, U eid 2, P evaluee N, P eid 3', |
|
264 |
'''SELECT rel_evaluee1.eid_to |
|
265 |
FROM evaluee_relation AS rel_evaluee1, todo_by_relation AS rel_todo_by0 |
|
266 |
WHERE rel_evaluee1.eid_to=rel_todo_by0.eid_from AND rel_todo_by0.eid_to=2 AND rel_evaluee1.eid_from=3'''), |
|
267 |
||
268 |
||
269 |
(' Any X,U WHERE C owned_by U, NOT X owned_by U, C eid 1, X eid 2', |
|
270 |
'''SELECT 2, rel_owned_by0.eid_to |
|
271 |
FROM owned_by_relation AS rel_owned_by0 |
|
272 |
WHERE rel_owned_by0.eid_from=1 AND NOT EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by1 WHERE rel_owned_by1.eid_from=2 AND rel_owned_by0.eid_to=rel_owned_by1.eid_to)'''), |
|
273 |
||
274 |
('Any GN WHERE X in_group G, G name GN, (G name "managers" OR EXISTS(X copain T, T login in ("comme", "cochon")))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
275 |
'''SELECT G.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
276 |
FROM cw_EGroup AS G, in_group_relation AS rel_in_group0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
277 |
WHERE rel_in_group0.eid_to=G.cw_eid AND ((G.cw_name=managers) OR (EXISTS(SELECT 1 FROM copain_relation AS rel_copain1, cw_EUser AS T WHERE rel_copain1.eid_from=rel_in_group0.eid_from AND rel_copain1.eid_to=T.cw_eid AND T.cw_login IN(comme, cochon))))'''), |
0 | 278 |
|
279 |
('Any C WHERE C is Card, EXISTS(X documented_by C)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
280 |
"""SELECT C.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
281 |
FROM cw_Card AS C |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
282 |
WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_to=C.cw_eid)"""), |
0 | 283 |
|
284 |
('Any C WHERE C is Card, EXISTS(X documented_by C, X eid 12)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
285 |
"""SELECT C.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
286 |
FROM cw_Card AS C |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
287 |
WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_from=12 AND rel_documented_by0.eid_to=C.cw_eid)"""), |
0 | 288 |
|
289 |
('Any T WHERE C is Card, C title T, EXISTS(X documented_by C, X eid 12)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
290 |
"""SELECT C.cw_title |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
291 |
FROM cw_Card AS C |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
292 |
WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_from=12 AND rel_documented_by0.eid_to=C.cw_eid)"""), |
0 | 293 |
|
294 |
('Any GN,L WHERE X in_group G, X login L, G name GN, EXISTS(X copain T, T login L, T login IN("comme", "cochon"))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
295 |
'''SELECT G.cw_name, X.cw_login |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
296 |
FROM cw_EGroup AS G, cw_EUser AS X, in_group_relation AS rel_in_group0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
297 |
WHERE rel_in_group0.eid_from=X.cw_eid AND rel_in_group0.eid_to=G.cw_eid AND EXISTS(SELECT 1 FROM copain_relation AS rel_copain1, cw_EUser AS T WHERE rel_copain1.eid_from=X.cw_eid AND rel_copain1.eid_to=T.cw_eid AND T.cw_login=X.cw_login AND T.cw_login IN(comme, cochon))'''), |
0 | 298 |
|
299 |
('Any X,S, MAX(T) GROUPBY X,S ORDERBY S WHERE X is EUser, T tags X, S eid IN(32), X in_state S', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
300 |
'''SELECT X.cw_eid, 32, MAX(rel_tags0.eid_from) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
301 |
FROM cw_EUser AS X, tags_relation AS rel_tags0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
302 |
WHERE rel_tags0.eid_to=X.cw_eid AND X.cw_in_state=32 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
303 |
GROUP BY X.cw_eid'''), |
0 | 304 |
|
305 |
('Any COUNT(S),CS GROUPBY CS ORDERBY 1 DESC LIMIT 10 WHERE S is Affaire, C is Societe, S concerne C, C nom CS, (EXISTS(S owned_by 1)) OR (EXISTS(S documented_by N, N title "published"))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
306 |
'''SELECT COUNT(rel_concerne0.eid_from), C.cw_nom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
307 |
FROM concerne_relation AS rel_concerne0, cw_Societe AS C |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
308 |
WHERE rel_concerne0.eid_to=C.cw_eid AND ((EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by1 WHERE rel_concerne0.eid_from=rel_owned_by1.eid_from AND rel_owned_by1.eid_to=1)) OR (EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by2, cw_Card AS N WHERE rel_concerne0.eid_from=rel_documented_by2.eid_from AND rel_documented_by2.eid_to=N.cw_eid AND N.cw_title=published))) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
309 |
GROUP BY C.cw_nom |
0 | 310 |
ORDER BY 1 DESC |
311 |
LIMIT 10'''), |
|
312 |
||
313 |
('Any X WHERE Y evaluee X, Y is EUser', |
|
314 |
'''SELECT rel_evaluee0.eid_to |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
315 |
FROM cw_EUser AS Y, evaluee_relation AS rel_evaluee0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
316 |
WHERE rel_evaluee0.eid_from=Y.cw_eid'''), |
0 | 317 |
|
318 |
('Any L WHERE X login "admin", X identity Y, Y login L', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
319 |
'''SELECT Y.cw_login |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
320 |
FROM cw_EUser AS X, cw_EUser AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
321 |
WHERE X.cw_login=admin AND X.cw_eid=Y.cw_eid'''), |
0 | 322 |
|
323 |
('Any L WHERE X login "admin", NOT X identity Y, Y login L', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
324 |
'''SELECT Y.cw_login |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
325 |
FROM cw_EUser AS X, cw_EUser AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
326 |
WHERE X.cw_login=admin AND NOT X.cw_eid=Y.cw_eid'''), |
0 | 327 |
|
328 |
('Any L WHERE X login "admin", X identity Y?, Y login L', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
329 |
'''SELECT Y.cw_login |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
330 |
FROM cw_EUser AS X LEFT OUTER JOIN cw_EUser AS Y ON (X.cw_eid=Y.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
331 |
WHERE X.cw_login=admin'''), |
0 | 332 |
|
333 |
('Any XN ORDERBY XN WHERE X name XN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
334 |
'''SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
335 |
FROM cw_Basket AS X |
0 | 336 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
337 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
338 |
FROM cw_ECache AS X |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
339 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
340 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
341 |
FROM cw_EConstraintType AS X |
0 | 342 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
343 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
344 |
FROM cw_EEType AS X |
0 | 345 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
346 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
347 |
FROM cw_EGroup AS X |
0 | 348 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
349 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
350 |
FROM cw_EPermission AS X |
0 | 351 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
352 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
353 |
FROM cw_ERType AS X |
0 | 354 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
355 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
356 |
FROM cw_File AS X |
0 | 357 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
358 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
359 |
FROM cw_Folder AS X |
0 | 360 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
361 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
362 |
FROM cw_Image AS X |
0 | 363 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
364 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
365 |
FROM cw_State AS X |
0 | 366 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
367 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
368 |
FROM cw_Tag AS X |
0 | 369 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
370 |
SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
371 |
FROM cw_Transition AS X |
0 | 372 |
ORDER BY 1'''), |
373 |
||
374 |
# ('Any XN WHERE X name XN GROUPBY XN', |
|
375 |
# ''''''), |
|
376 |
# ('Any XN, COUNT(X) WHERE X name XN GROUPBY XN', |
|
377 |
# ''''''), |
|
378 |
||
379 |
# DISTINCT, can use relatin under exists scope as principal |
|
380 |
('DISTINCT Any X,Y WHERE X name "EGroup", Y eid IN(1, 2, 3), EXISTS(X read_permission Y)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
381 |
'''SELECT DISTINCT X.cw_eid, rel_read_permission0.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
382 |
FROM cw_EEType AS X, read_permission_relation AS rel_read_permission0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
383 |
WHERE X.cw_name=EGroup AND rel_read_permission0.eid_to IN(1, 2, 3) AND EXISTS(SELECT 1 WHERE rel_read_permission0.eid_from=X.cw_eid) |
0 | 384 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
385 |
SELECT DISTINCT X.cw_eid, rel_read_permission0.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
386 |
FROM cw_ERType AS X, read_permission_relation AS rel_read_permission0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
387 |
WHERE X.cw_name=EGroup AND rel_read_permission0.eid_to IN(1, 2, 3) AND EXISTS(SELECT 1 WHERE rel_read_permission0.eid_from=X.cw_eid)'''), |
0 | 388 |
|
389 |
# no distinct, Y can't be invariant |
|
390 |
('Any X,Y WHERE X name "EGroup", Y eid IN(1, 2, 3), EXISTS(X read_permission Y)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
391 |
'''SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
392 |
FROM cw_EEType AS X, cw_EGroup AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
393 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 394 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
395 |
SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
396 |
FROM cw_EEType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
397 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 398 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
399 |
SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
400 |
FROM cw_EGroup AS Y, cw_ERType AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
401 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 402 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
403 |
SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
404 |
FROM cw_ERType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
405 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid)'''), |
0 | 406 |
|
407 |
# DISTINCT but NEGED exists, can't be invariant |
|
408 |
('DISTINCT Any X,Y WHERE X name "EGroup", Y eid IN(1, 2, 3), NOT EXISTS(X read_permission Y)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
409 |
'''SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
410 |
FROM cw_EEType AS X, cw_EGroup AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
411 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 412 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
413 |
SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
414 |
FROM cw_EEType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
415 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 416 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
417 |
SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
418 |
FROM cw_EGroup AS Y, cw_ERType AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
419 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 420 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
421 |
SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
422 |
FROM cw_ERType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
423 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid)'''), |
0 | 424 |
|
425 |
# should generate the same query as above |
|
426 |
('DISTINCT Any X,Y WHERE X name "EGroup", Y eid IN(1, 2, 3), NOT X read_permission Y', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
427 |
'''SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
428 |
FROM cw_EEType AS X, cw_EGroup AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
429 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 430 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
431 |
SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
432 |
FROM cw_EEType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
433 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 434 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
435 |
SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
436 |
FROM cw_EGroup AS Y, cw_ERType AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
437 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 438 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
439 |
SELECT DISTINCT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
440 |
FROM cw_ERType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
441 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid)'''), |
0 | 442 |
|
443 |
# neged relation, can't be inveriant |
|
444 |
('Any X,Y WHERE X name "EGroup", Y eid IN(1, 2, 3), NOT X read_permission Y', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
445 |
'''SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
446 |
FROM cw_EEType AS X, cw_EGroup AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
447 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 448 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
449 |
SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
450 |
FROM cw_EEType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
451 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 452 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
453 |
SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
454 |
FROM cw_EGroup AS Y, cw_ERType AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
455 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
0 | 456 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
457 |
SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
458 |
FROM cw_ERType AS X, cw_RQLExpression AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
459 |
WHERE X.cw_name=EGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid)'''), |
0 | 460 |
|
461 |
('Any MAX(X)+MIN(X), N GROUPBY N WHERE X name N;', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
462 |
'''SELECT (MAX(T1.C0) + MIN(T1.C0)), T1.C1 FROM (SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
463 |
FROM cw_Basket AS X |
0 | 464 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
465 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
466 |
FROM cw_ECache AS X |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
467 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
468 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
469 |
FROM cw_EConstraintType AS X |
0 | 470 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
471 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
472 |
FROM cw_EEType AS X |
0 | 473 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
474 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
475 |
FROM cw_EGroup AS X |
0 | 476 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
477 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
478 |
FROM cw_EPermission AS X |
0 | 479 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
480 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
481 |
FROM cw_ERType AS X |
0 | 482 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
483 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
484 |
FROM cw_File AS X |
0 | 485 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
486 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
487 |
FROM cw_Folder AS X |
0 | 488 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
489 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
490 |
FROM cw_Image AS X |
0 | 491 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
492 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
493 |
FROM cw_State AS X |
0 | 494 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
495 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
496 |
FROM cw_Tag AS X |
0 | 497 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
498 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
499 |
FROM cw_Transition AS X) AS T1 |
0 | 500 |
GROUP BY T1.C1'''), |
501 |
||
502 |
('Any MAX(X)+MIN(LENGTH(D)), N GROUPBY N ORDERBY 1, N, DF WHERE X name N, X data D, X data_format DF;', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
503 |
'''SELECT (MAX(T1.C1) + MIN(LENGTH(T1.C0))), T1.C2 FROM (SELECT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
504 |
FROM cw_File AS X |
0 | 505 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
506 |
SELECT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
507 |
FROM cw_Image AS X) AS T1 |
0 | 508 |
GROUP BY T1.C2 |
509 |
ORDER BY 1,2,T1.C3'''), |
|
510 |
||
511 |
('DISTINCT Any S ORDERBY R WHERE A is Affaire, A sujet S, A ref R', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
512 |
'''SELECT T1.C0 FROM (SELECT DISTINCT A.cw_sujet AS C0, A.cw_ref AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
513 |
FROM cw_Affaire AS A |
0 | 514 |
ORDER BY 2) AS T1'''), |
515 |
||
516 |
('DISTINCT Any MAX(X)+MIN(LENGTH(D)), N GROUPBY N ORDERBY 2, DF WHERE X name N, X data D, X data_format DF;', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
517 |
'''SELECT T1.C0,T1.C1 FROM (SELECT DISTINCT (MAX(T1.C1) + MIN(LENGTH(T1.C0))) AS C0, T1.C2 AS C1, T1.C3 AS C2 FROM (SELECT DISTINCT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
518 |
FROM cw_File AS X |
0 | 519 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
520 |
SELECT DISTINCT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
521 |
FROM cw_Image AS X) AS T1 |
0 | 522 |
GROUP BY T1.C2,T1.C3 |
523 |
ORDER BY 2,3) AS T1 |
|
524 |
'''), |
|
525 |
||
526 |
# ambiguity in EXISTS() -> should union the sub-query |
|
527 |
('Any T WHERE T is Tag, NOT T name in ("t1", "t2"), EXISTS(T tags X, X is IN (EUser, EGroup))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
528 |
'''SELECT T.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
529 |
FROM cw_Tag AS T |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
530 |
WHERE NOT (T.cw_name IN(t1, t2)) AND EXISTS(SELECT 1 FROM tags_relation AS rel_tags0, cw_EGroup AS X WHERE rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=X.cw_eid UNION SELECT 1 FROM tags_relation AS rel_tags1, cw_EUser AS X WHERE rel_tags1.eid_from=T.cw_eid AND rel_tags1.eid_to=X.cw_eid)'''), |
0 | 531 |
|
532 |
# must not use a relation in EXISTS scope to inline a variable |
|
533 |
('Any U WHERE U eid IN (1,2), EXISTS(X owned_by U)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
534 |
'''SELECT U.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
535 |
FROM cw_EUser AS U |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
536 |
WHERE U.cw_eid IN(1, 2) AND EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_to=U.cw_eid)'''), |
0 | 537 |
|
538 |
('Any U WHERE EXISTS(U eid IN (1,2), X owned_by U)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
539 |
'''SELECT U.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
540 |
FROM cw_EUser AS U |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
541 |
WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0 WHERE U.cw_eid IN(1, 2) AND rel_owned_by0.eid_to=U.cw_eid)'''), |
0 | 542 |
|
543 |
('Any COUNT(U) WHERE EXISTS (P owned_by U, P is IN (Note, Affaire))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
544 |
'''SELECT COUNT(U.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
545 |
FROM cw_EUser AS U |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
546 |
WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, cw_Affaire AS P WHERE rel_owned_by0.eid_from=P.cw_eid AND rel_owned_by0.eid_to=U.cw_eid UNION SELECT 1 FROM owned_by_relation AS rel_owned_by1, cw_Note AS P WHERE rel_owned_by1.eid_from=P.cw_eid AND rel_owned_by1.eid_to=U.cw_eid)'''), |
0 | 547 |
|
548 |
('Any MAX(X)', |
|
549 |
'''SELECT MAX(X.eid) |
|
550 |
FROM entities AS X'''), |
|
551 |
||
552 |
('Any MAX(X) WHERE X is Note', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
553 |
'''SELECT MAX(X.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
554 |
FROM cw_Note AS X'''), |
0 | 555 |
|
556 |
('Any X WHERE X eid > 12', |
|
557 |
'''SELECT X.eid |
|
558 |
FROM entities AS X |
|
559 |
WHERE X.eid>12'''), |
|
560 |
||
561 |
('Any X WHERE X eid > 12, X is Note', |
|
562 |
"""SELECT X.eid |
|
563 |
FROM entities AS X |
|
564 |
WHERE X.type='Note' AND X.eid>12"""), |
|
565 |
||
566 |
('Any X, T WHERE X eid > 12, X title T', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
567 |
"""SELECT X.cw_eid, X.cw_title |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
568 |
FROM cw_Bookmark AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
569 |
WHERE X.cw_eid>12 |
0 | 570 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
571 |
SELECT X.cw_eid, X.cw_title |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
572 |
FROM cw_Card AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
573 |
WHERE X.cw_eid>12 |
0 | 574 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
575 |
SELECT X.cw_eid, X.cw_title |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
576 |
FROM cw_EmailThread AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
577 |
WHERE X.cw_eid>12"""), |
0 | 578 |
|
579 |
('Any X', |
|
580 |
'''SELECT X.eid |
|
581 |
FROM entities AS X'''), |
|
582 |
||
583 |
('Any X GROUPBY X WHERE X eid 12', |
|
584 |
'''SELECT 12'''), |
|
585 |
||
586 |
('Any X GROUPBY X ORDERBY Y WHERE X eid 12, X login Y', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
587 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
588 |
FROM cw_EUser AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
589 |
WHERE X.cw_eid=12 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
590 |
GROUP BY X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
591 |
ORDER BY X.cw_login'''), |
0 | 592 |
|
593 |
('Any U,COUNT(X) GROUPBY U WHERE U eid 12, X owned_by U HAVING COUNT(X) > 10', |
|
594 |
'''SELECT rel_owned_by0.eid_to, COUNT(rel_owned_by0.eid_from) |
|
595 |
FROM owned_by_relation AS rel_owned_by0 |
|
596 |
WHERE rel_owned_by0.eid_to=12 |
|
597 |
GROUP BY rel_owned_by0.eid_to |
|
598 |
HAVING COUNT(rel_owned_by0.eid_from)>10'''), |
|
599 |
||
600 |
('DISTINCT Any X ORDERBY stockproc(X) WHERE U login X', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
601 |
'''SELECT T1.C0 FROM (SELECT DISTINCT U.cw_login AS C0, STOCKPROC(U.cw_login) AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
602 |
FROM cw_EUser AS U |
0 | 603 |
ORDER BY 2) AS T1'''), |
604 |
||
605 |
('DISTINCT Any X ORDERBY Y WHERE B bookmarked_by X, X login Y', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
606 |
'''SELECT T1.C0 FROM (SELECT DISTINCT X.cw_eid AS C0, X.cw_login AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
607 |
FROM bookmarked_by_relation AS rel_bookmarked_by0, cw_EUser AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
608 |
WHERE rel_bookmarked_by0.eid_to=X.cw_eid |
0 | 609 |
ORDER BY 2) AS T1'''), |
610 |
||
611 |
('DISTINCT Any X ORDERBY SN WHERE X in_state S, S name SN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
612 |
'''SELECT T1.C0 FROM (SELECT DISTINCT X.cw_eid AS C0, S.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
613 |
FROM cw_Affaire AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
614 |
WHERE X.cw_in_state=S.cw_eid |
0 | 615 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
616 |
SELECT DISTINCT X.cw_eid AS C0, S.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
617 |
FROM cw_EUser AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
618 |
WHERE X.cw_in_state=S.cw_eid |
0 | 619 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
620 |
SELECT DISTINCT X.cw_eid AS C0, S.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
621 |
FROM cw_Note AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
622 |
WHERE X.cw_in_state=S.cw_eid |
0 | 623 |
ORDER BY 2) AS T1'''), |
624 |
||
625 |
] |
|
626 |
||
627 |
MULTIPLE_SEL = [ |
|
628 |
("DISTINCT Any X,Y where P is Personne, P nom X , P prenom Y;", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
629 |
'''SELECT DISTINCT P.cw_nom, P.cw_prenom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
630 |
FROM cw_Personne AS P'''), |
0 | 631 |
("Any X,Y where P is Personne, P nom X , P prenom Y, not P nom NULL;", |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
632 |
'''SELECT P.cw_nom, P.cw_prenom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
633 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
634 |
WHERE NOT (P.cw_nom IS NULL)'''), |
0 | 635 |
("Personne X,Y where X nom NX, Y nom NX, X eid XE, not Y eid XE", |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
636 |
'''SELECT X.cw_eid, Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
637 |
FROM cw_Personne AS X, cw_Personne AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
638 |
WHERE Y.cw_nom=X.cw_nom AND NOT (Y.cw_eid=X.cw_eid)''') |
0 | 639 |
] |
640 |
||
641 |
NEGATIONS = [ |
|
642 |
("Personne X WHERE NOT X evaluee Y;", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
643 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
644 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
645 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=X.cw_eid)'''), |
0 | 646 |
|
647 |
("Note N WHERE NOT X evaluee N, X eid 0", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
648 |
'''SELECT N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
649 |
FROM cw_Note AS N |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
650 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=0 AND rel_evaluee0.eid_to=N.cw_eid)'''), |
0 | 651 |
|
652 |
('Any X WHERE NOT X travaille S, X is Personne', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
653 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
654 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
655 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid)'''), |
0 | 656 |
|
657 |
("Personne P where not P datenaiss TODAY", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
658 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
659 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
660 |
WHERE NOT (DATE(P.cw_datenaiss)=CURRENT_DATE)'''), |
0 | 661 |
|
662 |
("Personne P where NOT P concerne A", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
663 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
664 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
665 |
WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_from=P.cw_eid)'''), |
0 | 666 |
|
667 |
("Affaire A where not P concerne A", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
668 |
'''SELECT A.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
669 |
FROM cw_Affaire AS A |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
670 |
WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_to=A.cw_eid)'''), |
0 | 671 |
("Personne P where not P concerne A, A sujet ~= 'TEST%'", |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
672 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
673 |
FROM cw_Affaire AS A, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
674 |
WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_from=P.cw_eid AND rel_concerne0.eid_to=A.cw_eid) AND A.cw_sujet ILIKE TEST%'''), |
0 | 675 |
|
676 |
('Any S WHERE NOT T eid 28258, T tags S', |
|
677 |
'''SELECT rel_tags0.eid_to |
|
678 |
FROM tags_relation AS rel_tags0 |
|
679 |
WHERE NOT (rel_tags0.eid_from=28258)'''), |
|
680 |
||
681 |
('Any S WHERE T is Tag, T name TN, NOT T eid 28258, T tags S, S name SN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
682 |
'''SELECT S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
683 |
FROM cw_EGroup AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
684 |
WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid |
0 | 685 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
686 |
SELECT S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
687 |
FROM cw_State AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
688 |
WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid |
0 | 689 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
690 |
SELECT S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
691 |
FROM cw_Tag AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
692 |
WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid'''), |
0 | 693 |
|
694 |
||
695 |
('Any X,Y WHERE X created_by Y, X eid 5, NOT Y eid 6', |
|
696 |
'''SELECT 5, rel_created_by0.eid_to |
|
697 |
FROM created_by_relation AS rel_created_by0 |
|
698 |
WHERE rel_created_by0.eid_from=5 AND NOT (rel_created_by0.eid_to=6)'''), |
|
699 |
||
700 |
('Note X WHERE NOT Y evaluee X', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
701 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
702 |
FROM cw_Note AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
703 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_to=X.cw_eid)'''), |
0 | 704 |
|
705 |
('Any Y WHERE NOT Y evaluee X', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
706 |
'''SELECT Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
707 |
FROM cw_Division AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
708 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
0 | 709 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
710 |
SELECT Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
711 |
FROM cw_EUser AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
712 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
0 | 713 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
714 |
SELECT Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
715 |
FROM cw_Personne AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
716 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
0 | 717 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
718 |
SELECT Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
719 |
FROM cw_Societe AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
720 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
0 | 721 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
722 |
SELECT Y.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
723 |
FROM cw_SubDivision AS Y |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
724 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid)'''), |
0 | 725 |
|
726 |
('Any X WHERE NOT Y evaluee X, Y is EUser', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
727 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
728 |
FROM cw_Note AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
729 |
WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0,cw_EUser AS Y WHERE rel_evaluee0.eid_from=Y.cw_eid AND rel_evaluee0.eid_to=X.cw_eid)'''), |
0 | 730 |
|
731 |
('Any X,T WHERE X title T, NOT X is Bookmark', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
732 |
'''SELECT DISTINCT X.cw_eid, X.cw_title |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
733 |
FROM cw_Card AS X |
0 | 734 |
UNION |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
735 |
SELECT DISTINCT X.cw_eid, X.cw_title |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
736 |
FROM cw_EmailThread AS X'''), |
0 | 737 |
|
738 |
('Any K,V WHERE P is EProperty, P pkey K, P value V, NOT P for_user U', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
739 |
'''SELECT DISTINCT P.cw_pkey, P.cw_value |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
740 |
FROM cw_EProperty AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
741 |
WHERE P.cw_for_user IS NULL'''), |
0 | 742 |
|
339
c0a0ce6c0428
in some cases (eg ambiguous neged relations), INTERSECT should be used instead of DISTINCT
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
47
diff
changeset
|
743 |
('Any S WHERE NOT X in_state S, X is IN(Affaire, EUser)', |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
744 |
'''SELECT DISTINCT S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
745 |
FROM cw_Affaire AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
746 |
WHERE (X.cw_in_state IS NULL OR X.cw_in_state!=S.cw_eid) |
339
c0a0ce6c0428
in some cases (eg ambiguous neged relations), INTERSECT should be used instead of DISTINCT
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
47
diff
changeset
|
747 |
INTERSECT |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
748 |
SELECT DISTINCT S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
749 |
FROM cw_EUser AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
750 |
WHERE (X.cw_in_state IS NULL OR X.cw_in_state!=S.cw_eid)'''), |
0 | 751 |
] |
752 |
||
753 |
OUTER_JOIN = [ |
|
754 |
('Any X,S WHERE X travaille S?', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
755 |
'''SELECT X.cw_eid, rel_travaille0.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
756 |
FROM cw_Personne AS X LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_from=X.cw_eid)''' |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
757 |
#SELECT X.cw_eid, S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
758 |
#FROM cw_Personne AS X LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_from=X.cw_eid) LEFT OUTER JOIN cw_Societe AS S ON (rel_travaille0.eid_to=S.cw_eid)''' |
0 | 759 |
), |
760 |
('Any S,X WHERE X? travaille S, S is Societe', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
761 |
'''SELECT S.cw_eid, rel_travaille0.eid_from |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
762 |
FROM cw_Societe AS S LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_to=S.cw_eid)''' |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
763 |
#SELECT S.cw_eid, X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
764 |
#FROM cw_Societe AS S LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_to=S.cw_eid) LEFT OUTER JOIN cw_Personne AS X ON (rel_travaille0.eid_from=X.cw_eid)''' |
0 | 765 |
), |
766 |
||
767 |
('Any N,A WHERE N inline1 A?', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
768 |
'''SELECT N.cw_eid, N.cw_inline1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
769 |
FROM cw_Note AS N'''), |
0 | 770 |
|
771 |
('Any SN WHERE X from_state S?, S name SN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
772 |
'''SELECT S.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
773 |
FROM cw_TrInfo AS X LEFT OUTER JOIN cw_State AS S ON (X.cw_from_state=S.cw_eid)''' |
0 | 774 |
), |
775 |
||
776 |
('Any A,N WHERE N? inline1 A', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
777 |
'''SELECT A.cw_eid, N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
778 |
FROM cw_Affaire AS A LEFT OUTER JOIN cw_Note AS N ON (N.cw_inline1=A.cw_eid)''' |
0 | 779 |
), |
780 |
||
781 |
('Any A,B,C,D,E,F,G WHERE A eid 12,A creation_date B,A modification_date C,A comment D,A from_state E?,A to_state F?,A wf_info_for G?', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
782 |
'''SELECT A.cw_eid, A.cw_creation_date, A.cw_modification_date, A.cw_comment, A.cw_from_state, A.cw_to_state, A.cw_wf_info_for |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
783 |
FROM cw_TrInfo AS A |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
784 |
WHERE A.cw_eid=12'''), |
0 | 785 |
|
786 |
('Any FS,TS,C,D,U ORDERBY D DESC WHERE WF wf_info_for X,WF from_state FS?, WF to_state TS, WF comment C,WF creation_date D, WF owned_by U, X eid 1', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
787 |
'''SELECT WF.cw_from_state, WF.cw_to_state, WF.cw_comment, WF.cw_creation_date, rel_owned_by0.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
788 |
FROM cw_TrInfo AS WF, owned_by_relation AS rel_owned_by0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
789 |
WHERE WF.cw_wf_info_for=1 AND WF.cw_to_state IS NOT NULL AND rel_owned_by0.eid_from=WF.cw_eid |
0 | 790 |
ORDER BY 4 DESC'''), |
791 |
||
792 |
('Any X WHERE X is Affaire, S is Societe, EXISTS(X owned_by U OR (X concerne S?, S owned_by U))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
793 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
794 |
FROM cw_Affaire AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
795 |
WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, cw_EUser AS U, cw_Affaire AS A LEFT OUTER JOIN concerne_relation AS rel_concerne1 ON (rel_concerne1.eid_from=A.cw_eid) LEFT OUTER JOIN cw_Societe AS S ON (rel_concerne1.eid_to=S.cw_eid), owned_by_relation AS rel_owned_by2 WHERE ((rel_owned_by0.eid_from=A.cw_eid AND rel_owned_by0.eid_to=U.cw_eid) OR (rel_owned_by2.eid_from=S.cw_eid AND rel_owned_by2.eid_to=U.cw_eid)) AND X.cw_eid=A.cw_eid)'''), |
0 | 796 |
|
797 |
('Any C,M WHERE C travaille G?, G evaluee M?, G is Societe', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
798 |
'''SELECT C.cw_eid, rel_evaluee1.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
799 |
FROM cw_Personne AS C LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_from=C.cw_eid) LEFT OUTER JOIN cw_Societe AS G ON (rel_travaille0.eid_to=G.cw_eid) LEFT OUTER JOIN evaluee_relation AS rel_evaluee1 ON (rel_evaluee1.eid_from=G.cw_eid)''' |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
800 |
#SELECT C.cw_eid, M.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
801 |
#FROM cw_Personne AS C LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_from=C.cw_eid) LEFT OUTER JOIN cw_Societe AS G ON (rel_travaille0.eid_to=G.cw_eid) LEFT OUTER JOIN evaluee_relation AS rel_evaluee1 ON (rel_evaluee1.eid_from=G.cw_eid) LEFT OUTER JOIN cw_Note AS M ON (rel_evaluee1.eid_to=M.cw_eid)''' |
0 | 802 |
), |
803 |
||
804 |
('Any A,C WHERE A documented_by C?, (C is NULL) OR (EXISTS(C require_permission F, ' |
|
805 |
'F name "read", F require_group E, U in_group E)), U eid 1', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
806 |
'''SELECT A.cw_eid, rel_documented_by0.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
807 |
FROM cw_Affaire AS A LEFT OUTER JOIN documented_by_relation AS rel_documented_by0 ON (rel_documented_by0.eid_from=A.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
808 |
WHERE ((rel_documented_by0.eid_to IS NULL) OR (EXISTS(SELECT 1 FROM require_permission_relation AS rel_require_permission1, cw_EPermission AS F, require_group_relation AS rel_require_group2, in_group_relation AS rel_in_group3 WHERE rel_documented_by0.eid_to=rel_require_permission1.eid_from AND rel_require_permission1.eid_to=F.cw_eid AND F.cw_name=read AND rel_require_group2.eid_from=F.cw_eid AND rel_in_group3.eid_to=rel_require_group2.eid_to AND rel_in_group3.eid_from=1)))'''), |
0 | 809 |
|
810 |
("Any X WHERE X eid 12, P? connait X", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
811 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
812 |
FROM cw_Personne AS X LEFT OUTER JOIN connait_relation AS rel_connait0 ON (rel_connait0.eid_to=12) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
813 |
WHERE X.cw_eid=12''' |
0 | 814 |
#SELECT 12 |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
815 |
#FROM cw_Personne AS X LEFT OUTER JOIN connait_relation AS rel_connait0 ON (rel_connait0.eid_to=12) LEFT OUTER JOIN Personne AS P ON (rel_connait0.eid_from=P.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
816 |
#WHERE X.cw_eid=12''' |
0 | 817 |
), |
818 |
||
819 |
('Any GN, TN ORDERBY GN WHERE T tags G?, T name TN, G name GN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
820 |
'''SELECT _T0.C1, T.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
821 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN (SELECT G.cw_eid AS C0, G.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
822 |
FROM cw_EGroup AS G |
0 | 823 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
824 |
SELECT G.cw_eid AS C0, G.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
825 |
FROM cw_State AS G |
0 | 826 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
827 |
SELECT G.cw_eid AS C0, G.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
828 |
FROM cw_Tag AS G) AS _T0 ON (rel_tags0.eid_to=_T0.C0) |
0 | 829 |
ORDER BY 1'''), |
830 |
||
831 |
||
832 |
# optional variable with additional restriction |
|
833 |
('Any T,G WHERE T tags G?, G name "hop", G is EGroup', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
834 |
'''SELECT T.cw_eid, G.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
835 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_EGroup AS G ON (rel_tags0.eid_to=G.cw_eid AND G.cw_name=hop)'''), |
0 | 836 |
|
837 |
# optional variable with additional invariant restriction |
|
838 |
('Any T,G WHERE T tags G?, G eid 12', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
839 |
'''SELECT T.cw_eid, rel_tags0.eid_to |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
840 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=12)'''), |
0 | 841 |
|
842 |
# optional variable with additional restriction appearing before the relation |
|
843 |
('Any T,G WHERE G name "hop", T tags G?, G is EGroup', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
844 |
'''SELECT T.cw_eid, G.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
845 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_EGroup AS G ON (rel_tags0.eid_to=G.cw_eid AND G.cw_name=hop)'''), |
0 | 846 |
|
847 |
# optional variable with additional restriction on inlined relation |
|
848 |
# XXX the expected result should be as the query below. So what, raise BadRQLQuery ? |
|
849 |
('Any T,G,S WHERE T tags G?, G in_state S, S name "hop", G is EUser', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
850 |
'''SELECT T.cw_eid, G.cw_eid, S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
851 |
FROM cw_State AS S, cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_EUser AS G ON (rel_tags0.eid_to=G.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
852 |
WHERE G.cw_in_state=S.cw_eid AND S.cw_name=hop |
0 | 853 |
'''), |
854 |
||
855 |
# optional variable with additional invariant restriction on an inlined relation |
|
856 |
('Any T,G,S WHERE T tags G, G in_state S?, S eid 1, G is EUser', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
857 |
'''SELECT rel_tags0.eid_from, G.cw_eid, G.cw_in_state |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
858 |
FROM cw_EUser AS G, tags_relation AS rel_tags0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
859 |
WHERE rel_tags0.eid_to=G.cw_eid AND (G.cw_in_state=1 OR G.cw_in_state IS NULL)'''), |
0 | 860 |
|
861 |
# two optional variables with additional invariant restriction on an inlined relation |
|
862 |
('Any T,G,S WHERE T tags G?, G in_state S?, S eid 1, G is EUser', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
863 |
'''SELECT T.cw_eid, G.cw_eid, G.cw_in_state |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
864 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_EUser AS G ON (rel_tags0.eid_to=G.cw_eid AND (G.cw_in_state=1 OR G.cw_in_state IS NULL))'''), |
0 | 865 |
|
866 |
# two optional variables with additional restriction on an inlined relation |
|
867 |
('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop", G is EUser', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
868 |
'''SELECT T.cw_eid, G.cw_eid, S.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
869 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_EUser AS G ON (rel_tags0.eid_to=G.cw_eid) LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop)'''), |
0 | 870 |
|
871 |
# two optional variables with additional restriction on an ambigous inlined relation |
|
872 |
('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
873 |
'''SELECT T.cw_eid, _T0.C0, _T0.C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
874 |
FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN (SELECT G.cw_eid AS C0, S.cw_eid AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
875 |
FROM cw_Affaire AS G LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop) |
0 | 876 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
877 |
SELECT G.cw_eid AS C0, S.cw_eid AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
878 |
FROM cw_EUser AS G LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop) |
0 | 879 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
880 |
SELECT G.cw_eid AS C0, S.cw_eid AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
881 |
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)'''), |
0 | 882 |
|
883 |
] |
|
884 |
||
885 |
VIRTUAL_VARS = [ |
|
886 |
("Personne P WHERE P travaille S, S tel T, S fax T, S is Societe;", |
|
887 |
'''SELECT rel_travaille0.eid_from |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
888 |
FROM cw_Societe AS S, travaille_relation AS rel_travaille0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
889 |
WHERE rel_travaille0.eid_to=S.cw_eid AND S.cw_fax=S.cw_tel'''), |
0 | 890 |
|
891 |
("Personne P where X eid 0, X creation_date D, P datenaiss < D, X is Affaire", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
892 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
893 |
FROM cw_Affaire AS X, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
894 |
WHERE X.cw_eid=0 AND P.cw_datenaiss<X.cw_creation_date'''), |
0 | 895 |
|
896 |
("Any N,T WHERE N is Note, N type T;", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
897 |
'''SELECT N.cw_eid, N.cw_type |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
898 |
FROM cw_Note AS N'''), |
0 | 899 |
|
900 |
("Personne P where X is Personne, X tel T, X fax F, P fax T+F", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
901 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
902 |
FROM cw_Personne AS P, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
903 |
WHERE P.cw_fax=(X.cw_tel + X.cw_fax)'''), |
0 | 904 |
|
905 |
("Personne P where X tel T, X fax F, P fax IN (T,F)", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
906 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
907 |
FROM cw_Division AS X, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
908 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax) |
0 | 909 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
910 |
SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
911 |
FROM cw_Personne AS P, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
912 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax) |
0 | 913 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
914 |
SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
915 |
FROM cw_Personne AS P, cw_Societe AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
916 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax) |
0 | 917 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
918 |
SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
919 |
FROM cw_Personne AS P, cw_SubDivision AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
920 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax)'''), |
0 | 921 |
|
922 |
("Personne P where X tel T, X fax F, P fax IN (T,F,0832542332)", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
923 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
924 |
FROM cw_Division AS X, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
925 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax, 832542332) |
0 | 926 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
927 |
SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
928 |
FROM cw_Personne AS P, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
929 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax, 832542332) |
0 | 930 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
931 |
SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
932 |
FROM cw_Personne AS P, cw_Societe AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
933 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax, 832542332) |
0 | 934 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
935 |
SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
936 |
FROM cw_Personne AS P, cw_SubDivision AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
937 |
WHERE P.cw_fax IN(X.cw_tel, X.cw_fax, 832542332)'''), |
0 | 938 |
] |
939 |
||
940 |
FUNCS = [ |
|
941 |
("Any COUNT(P) WHERE P is Personne", |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
942 |
'''SELECT COUNT(P.cw_eid) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
943 |
FROM cw_Personne AS P'''), |
0 | 944 |
## ("Personne X where X nom upper('TOTO')", |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
945 |
## '''SELECT X.cw_eid\nFROM cw_Personne AS X\nWHERE UPPER(X.cw_nom) = TOTO'''), |
0 | 946 |
## ("Personne X where X nom Y, UPPER(X) prenom upper(Y)", |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
947 |
## '''SELECT X.cw_eid\nFROM cw_Personne AS X\nWHERE UPPER(X.cw_prenom) = UPPER(X.cw_nom)'''), |
0 | 948 |
] |
949 |
||
950 |
SYMETRIC = [ |
|
951 |
('Any P WHERE X eid 0, X connait P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
952 |
'''SELECT DISTINCT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
953 |
FROM connait_relation AS rel_connait0, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
954 |
WHERE (rel_connait0.eid_from=0 AND rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_to=0 AND rel_connait0.eid_from=P.cw_eid)''' |
0 | 955 |
# '''SELECT rel_connait0.eid_to |
956 |
# FROM connait_relation AS rel_connait0 |
|
957 |
# WHERE rel_connait0.eid_from=0 |
|
958 |
# UNION |
|
959 |
# SELECT rel_connait0.eid_from |
|
960 |
# FROM connait_relation AS rel_connait0 |
|
961 |
# WHERE rel_connait0.eid_to=0''' |
|
962 |
), |
|
963 |
||
964 |
('Any P WHERE X connait P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
965 |
'''SELECT DISTINCT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
966 |
FROM connait_relation AS rel_connait0, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
967 |
WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid)''' |
0 | 968 |
), |
969 |
||
970 |
('Any X WHERE X connait P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
971 |
'''SELECT DISTINCT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
972 |
FROM connait_relation AS rel_connait0, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
973 |
WHERE (rel_connait0.eid_from=X.cw_eid OR rel_connait0.eid_to=X.cw_eid)''' |
0 | 974 |
), |
975 |
||
976 |
('Any P WHERE X eid 0, NOT X connait P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
977 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
978 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
979 |
WHERE NOT EXISTS(SELECT 1 FROM connait_relation AS rel_connait0 WHERE (rel_connait0.eid_from=0 AND rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_to=0 AND rel_connait0.eid_from=P.cw_eid))'''), |
0 | 980 |
|
981 |
('Any P WHERE NOT X connait P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
982 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
983 |
FROM cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
984 |
WHERE NOT EXISTS(SELECT 1 FROM connait_relation AS rel_connait0 WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid))'''), |
0 | 985 |
|
986 |
('Any X WHERE NOT X connait P', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
987 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
988 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
989 |
WHERE NOT EXISTS(SELECT 1 FROM connait_relation AS rel_connait0 WHERE (rel_connait0.eid_from=X.cw_eid OR rel_connait0.eid_to=X.cw_eid))'''), |
0 | 990 |
|
991 |
('Any P WHERE X connait P, P nom "nom"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
992 |
'''SELECT DISTINCT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
993 |
FROM connait_relation AS rel_connait0, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
994 |
WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid) AND P.cw_nom=nom'''), |
0 | 995 |
|
996 |
('Any X WHERE X connait P, P nom "nom"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
997 |
'''SELECT DISTINCT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
998 |
FROM connait_relation AS rel_connait0, cw_Personne AS P, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
999 |
WHERE (rel_connait0.eid_from=X.cw_eid AND rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_to=X.cw_eid AND rel_connait0.eid_from=P.cw_eid) AND P.cw_nom=nom''' |
0 | 1000 |
), |
1001 |
||
1002 |
('Any X ORDERBY X DESC LIMIT 9 WHERE E eid 0, E connait X', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1003 |
'''SELECT DISTINCT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1004 |
FROM connait_relation AS rel_connait0, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1005 |
WHERE (rel_connait0.eid_from=0 AND rel_connait0.eid_to=X.cw_eid OR rel_connait0.eid_to=0 AND rel_connait0.eid_from=X.cw_eid) |
0 | 1006 |
ORDER BY 1 DESC |
1007 |
LIMIT 9''' |
|
1008 |
), |
|
1009 |
||
1010 |
('DISTINCT Any P WHERE P connait S OR S connait P, S nom "chouette"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1011 |
'''SELECT DISTINCT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1012 |
FROM connait_relation AS rel_connait0, cw_Personne AS P, cw_Personne AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1013 |
WHERE (rel_connait0.eid_from=P.cw_eid AND rel_connait0.eid_to=S.cw_eid OR rel_connait0.eid_to=P.cw_eid AND rel_connait0.eid_from=S.cw_eid) AND S.cw_nom=chouette''' |
0 | 1014 |
) |
1015 |
] |
|
1016 |
||
1017 |
INLINE = [ |
|
1018 |
('Any P, L WHERE N ecrit_par P, P nom L, N eid 0', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1019 |
'''SELECT P.cw_eid, P.cw_nom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1020 |
FROM cw_Note AS N, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1021 |
WHERE N.cw_ecrit_par=P.cw_eid AND N.cw_eid=0'''), |
0 | 1022 |
|
1023 |
('Any N WHERE NOT N ecrit_par P, P nom "toto"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1024 |
'''SELECT DISTINCT N.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1025 |
FROM cw_Note AS N, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1026 |
WHERE (N.cw_ecrit_par IS NULL OR N.cw_ecrit_par!=P.cw_eid) AND P.cw_nom=toto'''), |
0 | 1027 |
|
1028 |
('Any P WHERE N ecrit_par P, N eid 0', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1029 |
'''SELECT N.cw_ecrit_par |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1030 |
FROM cw_Note AS N |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1031 |
WHERE N.cw_ecrit_par IS NOT NULL AND N.cw_eid=0'''), |
0 | 1032 |
|
1033 |
('Any P WHERE N ecrit_par P, P is Personne, N eid 0', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1034 |
'''SELECT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1035 |
FROM cw_Note AS N, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1036 |
WHERE N.cw_ecrit_par=P.cw_eid AND N.cw_eid=0'''), |
0 | 1037 |
|
1038 |
('Any P WHERE NOT N ecrit_par P, P is Personne, N eid 512', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1039 |
'''SELECT DISTINCT P.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1040 |
FROM cw_Note AS N, cw_Personne AS P |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1041 |
WHERE (N.cw_ecrit_par IS NULL OR N.cw_ecrit_par!=P.cw_eid) AND N.cw_eid=512'''), |
0 | 1042 |
|
1043 |
('Any S,ES,T WHERE S state_of ET, ET name "EUser", ES allowed_transition T, T destination_state S', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1044 |
'''SELECT T.cw_destination_state, rel_allowed_transition1.eid_from, T.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1045 |
FROM allowed_transition_relation AS rel_allowed_transition1, cw_EEType AS ET, cw_Transition AS T, state_of_relation AS rel_state_of0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1046 |
WHERE T.cw_destination_state=rel_state_of0.eid_from AND rel_state_of0.eid_to=ET.cw_eid AND ET.cw_name=EUser AND rel_allowed_transition1.eid_to=T.cw_eid'''), |
0 | 1047 |
('Any O WHERE S eid 0, S in_state O', |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1048 |
'''SELECT S.cw_in_state |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1049 |
FROM cw_Affaire AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1050 |
WHERE S.cw_eid=0 AND S.cw_in_state IS NOT NULL |
0 | 1051 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1052 |
SELECT S.cw_in_state |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1053 |
FROM cw_EUser AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1054 |
WHERE S.cw_eid=0 AND S.cw_in_state IS NOT NULL |
0 | 1055 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1056 |
SELECT S.cw_in_state |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1057 |
FROM cw_Note AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1058 |
WHERE S.cw_eid=0 AND S.cw_in_state IS NOT NULL''') |
0 | 1059 |
|
1060 |
] |
|
1061 |
||
438 | 1062 |
INTERSECT = [ |
1063 |
('Any SN WHERE NOT X in_state S, S name SN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1064 |
'''SELECT DISTINCT S.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1065 |
FROM cw_Affaire AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1066 |
WHERE (X.cw_in_state IS NULL OR X.cw_in_state!=S.cw_eid) |
438 | 1067 |
INTERSECT |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1068 |
SELECT DISTINCT S.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1069 |
FROM cw_EUser AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1070 |
WHERE (X.cw_in_state IS NULL OR X.cw_in_state!=S.cw_eid) |
438 | 1071 |
INTERSECT |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1072 |
SELECT DISTINCT S.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1073 |
FROM cw_Note AS X, cw_State AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1074 |
WHERE (X.cw_in_state IS NULL OR X.cw_in_state!=S.cw_eid)'''), |
0 | 1075 |
|
438 | 1076 |
('Any PN WHERE NOT X travaille S, X nom PN, S is IN(Division, Societe)', |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1077 |
'''SELECT X.cw_nom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1078 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1079 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0,cw_Division AS S WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) |
438 | 1080 |
INTERSECT ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1081 |
SELECT X.cw_nom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1082 |
FROM cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1083 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0,cw_Societe AS S WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid)'''), |
438 | 1084 |
|
1085 |
('Any PN WHERE NOT X travaille S, S nom PN, S is IN(Division, Societe)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1086 |
'''SELECT S.cw_nom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1087 |
FROM cw_Division AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1088 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=S.cw_eid) |
438 | 1089 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1090 |
SELECT S.cw_nom |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1091 |
FROM cw_Societe AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1092 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=S.cw_eid)'''), |
438 | 1093 |
|
1094 |
('Personne X WHERE NOT X travaille S, S nom "chouette"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1095 |
'''SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1096 |
FROM cw_Division AS S, cw_Personne AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1097 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) AND S.cw_nom=chouette |
438 | 1098 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1099 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1100 |
FROM cw_Personne AS X, cw_Societe AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1101 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) AND S.cw_nom=chouette |
438 | 1102 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1103 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1104 |
FROM cw_Personne AS X, cw_SubDivision AS S |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1105 |
WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) AND S.cw_nom=chouette'''), |
438 | 1106 |
|
1107 |
('Any X WHERE X is ET, ET eid 2', |
|
1108 |
'''SELECT rel_is0.eid_from |
|
1109 |
FROM is_relation AS rel_is0 |
|
1110 |
WHERE rel_is0.eid_to=2'''), |
|
1111 |
||
1112 |
] |
|
0 | 1113 |
from logilab.common.adbh import ADV_FUNC_HELPER_DIRECTORY |
1114 |
||
1115 |
class PostgresSQLGeneratorTC(RQLGeneratorTC): |
|
1116 |
schema = schema |
|
1117 |
||
1118 |
#capture = True |
|
1119 |
def setUp(self): |
|
1120 |
RQLGeneratorTC.setUp(self) |
|
1121 |
indexer = get_indexer('postgres', 'utf8') |
|
1122 |
dbms_helper = ADV_FUNC_HELPER_DIRECTORY['postgres'] |
|
1123 |
dbms_helper.fti_uid_attr = indexer.uid_attr |
|
1124 |
dbms_helper.fti_table = indexer.table |
|
1125 |
dbms_helper.fti_restriction_sql = indexer.restriction_sql |
|
1126 |
dbms_helper.fti_need_distinct_query = indexer.need_distinct |
|
1127 |
self.o = SQLGenerator(schema, dbms_helper) |
|
1128 |
||
1129 |
def _norm_sql(self, sql): |
|
1130 |
return sql.strip() |
|
1131 |
||
1132 |
def _check(self, rql, sql, varmap=None): |
|
1133 |
try: |
|
1134 |
union = self._prepare(rql) |
|
1135 |
r, args = self.o.generate(union, {'text': 'hip hop momo'}, |
|
1136 |
varmap=varmap) |
|
1137 |
self.assertLinesEquals((r % args).strip(), self._norm_sql(sql)) |
|
1138 |
except Exception, ex: |
|
1139 |
print rql |
|
1140 |
if 'r' in locals(): |
|
1141 |
print (r%args).strip() |
|
1142 |
print '!=' |
|
1143 |
print sql.strip() |
|
1144 |
raise |
|
1145 |
||
1146 |
def _parse(self, rqls): |
|
1147 |
for rql, sql in rqls: |
|
1148 |
yield self._check, rql, sql |
|
1149 |
||
1150 |
def _checkall(self, rql, sql): |
|
1151 |
try: |
|
1152 |
rqlst = self._prepare(rql) |
|
1153 |
r, args = self.o.generate(rqlst) |
|
1154 |
self.assertEqual((r.strip(), args), sql) |
|
1155 |
except Exception, ex: |
|
1156 |
print rql |
|
1157 |
if 'r' in locals(): |
|
1158 |
print r.strip() |
|
1159 |
print '!=' |
|
1160 |
print sql[0].strip() |
|
1161 |
raise |
|
1162 |
return |
|
1163 |
# rqlst, solutions = self._prepare(rql) |
|
1164 |
# for i, sol in enumerate(solutions): |
|
1165 |
# try: |
|
1166 |
# r, args = self.o.generate([(rqlst, sol)]) |
|
1167 |
# self.assertEqual((r.strip(), args), sqls[i]) |
|
1168 |
# except Exception, ex: |
|
1169 |
# print rql |
|
1170 |
# raise |
|
1171 |
||
1172 |
def test1(self): |
|
1173 |
self._checkall('Any count(RDEF) WHERE RDEF relation_type X, X eid %(x)s', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1174 |
("""SELECT COUNT(T1.C0) FROM (SELECT RDEF.cw_eid AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1175 |
FROM cw_EFRDef AS RDEF |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1176 |
WHERE RDEF.cw_relation_type=%(x)s |
0 | 1177 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1178 |
SELECT RDEF.cw_eid AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1179 |
FROM cw_ENFRDef AS RDEF |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1180 |
WHERE RDEF.cw_relation_type=%(x)s) AS T1""", {}), |
0 | 1181 |
) |
1182 |
||
1183 |
def test2(self): |
|
1184 |
self._checkall('Any X WHERE C comments X, C eid %(x)s', |
|
1185 |
('''SELECT rel_comments0.eid_to |
|
1186 |
FROM comments_relation AS rel_comments0 |
|
1187 |
WHERE rel_comments0.eid_from=%(x)s''', {}) |
|
1188 |
) |
|
1189 |
||
1190 |
def test_cache_1(self): |
|
1191 |
self._check('Any X WHERE X in_basket B, B eid 12', |
|
1192 |
'''SELECT rel_in_basket0.eid_from |
|
1193 |
FROM in_basket_relation AS rel_in_basket0 |
|
1194 |
WHERE rel_in_basket0.eid_to=12''') |
|
1195 |
||
1196 |
self._check('Any X WHERE X in_basket B, B eid 12', |
|
1197 |
'''SELECT rel_in_basket0.eid_from |
|
1198 |
FROM in_basket_relation AS rel_in_basket0 |
|
1199 |
WHERE rel_in_basket0.eid_to=12''') |
|
1200 |
||
1201 |
def test_varmap(self): |
|
1202 |
self._check('Any X,L WHERE X is EUser, X in_group G, X login L, G name "users"', |
|
1203 |
'''SELECT T00.x, T00.l |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1204 |
FROM T00, cw_EGroup AS G, in_group_relation AS rel_in_group0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1205 |
WHERE rel_in_group0.eid_from=T00.x AND rel_in_group0.eid_to=G.cw_eid AND G.cw_name=users''', |
0 | 1206 |
varmap={'X': 'T00.x', 'X.login': 'T00.l'}) |
1207 |
self._check('Any X,L,GN WHERE X is EUser, X in_group G, X login L, G name GN', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1208 |
'''SELECT T00.x, T00.l, G.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1209 |
FROM T00, cw_EGroup AS G, in_group_relation AS rel_in_group0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1210 |
WHERE rel_in_group0.eid_from=T00.x AND rel_in_group0.eid_to=G.cw_eid''', |
0 | 1211 |
varmap={'X': 'T00.x', 'X.login': 'T00.l'}) |
1212 |
||
1213 |
def test_parser_parse(self): |
|
1214 |
for t in self._parse(PARSER): |
|
1215 |
yield t |
|
1216 |
||
1217 |
def test_basic_parse(self): |
|
1218 |
for t in self._parse(BASIC): |
|
1219 |
yield t |
|
1220 |
||
1221 |
def test_advanced_parse(self): |
|
1222 |
for t in self._parse(ADVANCED): |
|
1223 |
yield t |
|
1224 |
||
1225 |
def test_outer_join_parse(self): |
|
1226 |
for t in self._parse(OUTER_JOIN): |
|
1227 |
yield t |
|
1228 |
||
1229 |
def test_virtual_vars_parse(self): |
|
1230 |
for t in self._parse(VIRTUAL_VARS): |
|
1231 |
yield t |
|
1232 |
||
1233 |
def test_multiple_sel_parse(self): |
|
1234 |
for t in self._parse(MULTIPLE_SEL): |
|
1235 |
yield t |
|
1236 |
||
1237 |
def test_functions(self): |
|
1238 |
for t in self._parse(FUNCS): |
|
1239 |
yield t |
|
1240 |
||
1241 |
def test_negation(self): |
|
1242 |
for t in self._parse(NEGATIONS): |
|
1243 |
yield t |
|
438 | 1244 |
|
1245 |
def test_intersection(self): |
|
1246 |
for t in self._parse(INTERSECT): |
|
1247 |
yield t |
|
0 | 1248 |
|
1249 |
def test_union(self): |
|
1250 |
for t in self._parse(( |
|
1251 |
('(Any N ORDERBY 1 WHERE X name N, X is State)' |
|
1252 |
' UNION ' |
|
1253 |
'(Any NN ORDERBY 1 WHERE XX name NN, XX is Transition)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1254 |
'''(SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1255 |
FROM cw_State AS X |
0 | 1256 |
ORDER BY 1) |
1257 |
UNION ALL |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1258 |
(SELECT XX.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1259 |
FROM cw_Transition AS XX |
0 | 1260 |
ORDER BY 1)'''), |
1261 |
)): |
|
1262 |
yield t |
|
1263 |
||
1264 |
def test_subquery(self): |
|
1265 |
for t in self._parse(( |
|
1266 |
||
1267 |
('Any N ORDERBY 1 WITH N BEING ' |
|
1268 |
'((Any N WHERE X name N, X is State)' |
|
1269 |
' UNION ' |
|
1270 |
'(Any NN WHERE XX name NN, XX is Transition))', |
|
1271 |
'''SELECT _T0.C0 |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1272 |
FROM ((SELECT X.cw_name AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1273 |
FROM cw_State AS X) |
0 | 1274 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1275 |
(SELECT XX.cw_name AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1276 |
FROM cw_Transition AS XX)) AS _T0 |
0 | 1277 |
ORDER BY 1'''), |
1278 |
||
1279 |
('Any N,NX ORDERBY NX WITH N,NX BEING ' |
|
1280 |
'((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
|
1281 |
' UNION ' |
|
1282 |
'(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
|
1283 |
'''SELECT _T0.C0, _T0.C1 |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1284 |
FROM ((SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1285 |
FROM cw_State AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1286 |
GROUP BY X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1287 |
HAVING COUNT(X.cw_eid)>1) |
0 | 1288 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1289 |
(SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1290 |
FROM cw_Transition AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1291 |
GROUP BY X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1292 |
HAVING COUNT(X.cw_eid)>1)) AS _T0 |
0 | 1293 |
ORDER BY 2'''), |
1294 |
||
1295 |
('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
|
1296 |
'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
|
1297 |
' (Any X, N WHERE X name N, X is Transition))', |
|
1298 |
'''SELECT _T0.C1, COUNT(_T0.C0) |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1299 |
FROM ((SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1300 |
FROM cw_State AS X) |
0 | 1301 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1302 |
(SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1303 |
FROM cw_Transition AS X)) AS _T0 |
0 | 1304 |
GROUP BY _T0.C1 |
1305 |
HAVING COUNT(_T0.C0)>1'''), |
|
1306 |
||
1307 |
('Any ETN,COUNT(X) GROUPBY ETN WHERE X is ET, ET name ETN ' |
|
1308 |
'WITH X BEING ((Any X WHERE X is Societe) UNION (Any X WHERE X is Affaire, (EXISTS(X owned_by 1)) OR ((EXISTS(D concerne B?, B owned_by 1, X identity D, B is Note)) OR (EXISTS(F concerne E?, E owned_by 1, E is Societe, X identity F)))))', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1309 |
'''SELECT ET.cw_name, COUNT(_T0.C0) |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1310 |
FROM ((SELECT X.cw_eid AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1311 |
FROM cw_Societe AS X) |
0 | 1312 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1313 |
(SELECT X.cw_eid AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1314 |
FROM cw_Affaire AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1315 |
WHERE ((EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_from=X.cw_eid AND rel_owned_by0.eid_to=1)) OR (((EXISTS(SELECT 1 FROM cw_Affaire AS D LEFT OUTER JOIN concerne_relation AS rel_concerne1 ON (rel_concerne1.eid_from=D.cw_eid) LEFT OUTER JOIN cw_Note AS B ON (rel_concerne1.eid_to=B.cw_eid), owned_by_relation AS rel_owned_by2 WHERE rel_owned_by2.eid_from=B.cw_eid AND rel_owned_by2.eid_to=1 AND X.cw_eid=D.cw_eid)) OR (EXISTS(SELECT 1 FROM cw_Affaire AS F LEFT OUTER JOIN concerne_relation AS rel_concerne3 ON (rel_concerne3.eid_from=F.cw_eid) LEFT OUTER JOIN cw_Societe AS E ON (rel_concerne3.eid_to=E.cw_eid), owned_by_relation AS rel_owned_by4 WHERE rel_owned_by4.eid_from=E.cw_eid AND rel_owned_by4.eid_to=1 AND X.cw_eid=F.cw_eid))))))) AS _T0, cw_EEType AS ET, is_relation AS rel_is0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1316 |
WHERE rel_is0.eid_from=_T0.C0 AND rel_is0.eid_to=ET.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1317 |
GROUP BY ET.cw_name'''), |
0 | 1318 |
)): |
1319 |
yield t |
|
1320 |
||
1321 |
||
1322 |
def test_subquery_error(self): |
|
1323 |
rql = ('Any N WHERE X name N WITH X BEING ' |
|
1324 |
'((Any X WHERE X is State)' |
|
1325 |
' UNION ' |
|
1326 |
' (Any X WHERE X is Transition))') |
|
1327 |
rqlst = self._prepare(rql) |
|
1328 |
self.assertRaises(BadRQLQuery, self.o.generate, rqlst) |
|
1329 |
||
1330 |
def test_symetric(self): |
|
1331 |
for t in self._parse(SYMETRIC): |
|
1332 |
yield t |
|
1333 |
||
1334 |
def test_inline(self): |
|
1335 |
for t in self._parse(INLINE): |
|
1336 |
yield t |
|
1337 |
||
1338 |
def test_has_text(self): |
|
1339 |
for t in self._parse(( |
|
1340 |
('Any X WHERE X has_text "toto tata"', |
|
1341 |
"""SELECT appears0.uid |
|
1342 |
FROM appears AS appears0 |
|
1343 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata')"""), |
|
1344 |
||
1345 |
('Personne X WHERE X has_text "toto tata"', |
|
1346 |
"""SELECT X.eid |
|
1347 |
FROM appears AS appears0, entities AS X |
|
1348 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.eid AND X.type='Personne'"""), |
|
1349 |
||
1350 |
('Personne X WHERE X has_text %(text)s', |
|
1351 |
"""SELECT X.eid |
|
1352 |
FROM appears AS appears0, entities AS X |
|
1353 |
WHERE appears0.words @@ to_tsquery('default', 'hip&hop&momo') AND appears0.uid=X.eid AND X.type='Personne'"""), |
|
1354 |
||
1355 |
('Any X WHERE X has_text "toto tata", X name "tutu"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1356 |
"""SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1357 |
FROM appears AS appears0, cw_Basket AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1358 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1359 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1360 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1361 |
FROM appears AS appears0, cw_File AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1362 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1363 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1364 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1365 |
FROM appears AS appears0, cw_Folder AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1366 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1367 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1368 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1369 |
FROM appears AS appears0, cw_Image AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1370 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1371 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1372 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1373 |
FROM appears AS appears0, cw_State AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1374 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1375 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1376 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1377 |
FROM appears AS appears0, cw_Tag AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1378 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1379 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1380 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1381 |
FROM appears AS appears0, cw_Transition AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1382 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu"""), |
0 | 1383 |
|
1384 |
('Personne X where X has_text %(text)s, X travaille S, S has_text %(text)s', |
|
1385 |
"""SELECT X.eid |
|
1386 |
FROM appears AS appears0, appears AS appears2, entities AS X, travaille_relation AS rel_travaille1 |
|
1387 |
WHERE appears0.words @@ to_tsquery('default', 'hip&hop&momo') AND appears0.uid=X.eid AND X.type='Personne' AND X.eid=rel_travaille1.eid_from AND appears2.uid=rel_travaille1.eid_to AND appears2.words @@ to_tsquery('default', 'hip&hop&momo')"""), |
|
1388 |
)): |
|
1389 |
yield t |
|
1390 |
||
1391 |
||
1392 |
def test_from_clause_needed(self): |
|
1393 |
queries = [("Any 1 WHERE EXISTS(T is EGroup, T name 'managers')", |
|
1394 |
'''SELECT 1 |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1395 |
WHERE EXISTS(SELECT 1 FROM cw_EGroup AS T WHERE T.cw_name=managers)'''), |
0 | 1396 |
('Any X,Y WHERE NOT X created_by Y, X eid 5, Y eid 6', |
1397 |
'''SELECT 5, 6 |
|
1398 |
WHERE NOT EXISTS(SELECT 1 FROM created_by_relation AS rel_created_by0 WHERE rel_created_by0.eid_from=5 AND rel_created_by0.eid_to=6)'''), |
|
1399 |
] |
|
1400 |
for t in self._parse(queries): |
|
1401 |
yield t |
|
1402 |
||
1403 |
def test_ambigous_exists_no_from_clause(self): |
|
1404 |
self._check('Any COUNT(U) WHERE U eid 1, EXISTS (P owned_by U, P is IN (Note, Affaire))', |
|
1405 |
'''SELECT COUNT(1) |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1406 |
WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, cw_Affaire AS P WHERE rel_owned_by0.eid_from=P.cw_eid AND rel_owned_by0.eid_to=1 UNION SELECT 1 FROM owned_by_relation AS rel_owned_by1, cw_Note AS P WHERE rel_owned_by1.eid_from=P.cw_eid AND rel_owned_by1.eid_to=1)''') |
0 | 1407 |
|
1408 |
||
1409 |
class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC): |
|
1410 |
||
1411 |
def setUp(self): |
|
1412 |
RQLGeneratorTC.setUp(self) |
|
1413 |
indexer = get_indexer('sqlite', 'utf8') |
|
1414 |
dbms_helper = ADV_FUNC_HELPER_DIRECTORY['sqlite'] |
|
1415 |
dbms_helper.fti_uid_attr = indexer.uid_attr |
|
1416 |
dbms_helper.fti_table = indexer.table |
|
1417 |
dbms_helper.fti_restriction_sql = indexer.restriction_sql |
|
1418 |
dbms_helper.fti_need_distinct_query = indexer.need_distinct |
|
1419 |
self.o = SQLGenerator(schema, dbms_helper) |
|
1420 |
||
1421 |
def _norm_sql(self, sql): |
|
438 | 1422 |
return sql.strip().replace(' ILIKE ', ' LIKE ').replace('\nINTERSECT ALL\n', '\nINTERSECT\n') |
0 | 1423 |
|
1424 |
def test_union(self): |
|
1425 |
for t in self._parse(( |
|
1426 |
('(Any N ORDERBY 1 WHERE X name N, X is State)' |
|
1427 |
' UNION ' |
|
1428 |
'(Any NN ORDERBY 1 WHERE XX name NN, XX is Transition)', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1429 |
'''SELECT X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1430 |
FROM cw_State AS X |
0 | 1431 |
ORDER BY 1 |
1432 |
UNION ALL |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1433 |
SELECT XX.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1434 |
FROM cw_Transition AS XX |
0 | 1435 |
ORDER BY 1'''), |
1436 |
)): |
|
1437 |
yield t |
|
1438 |
||
1439 |
||
1440 |
def test_subquery(self): |
|
1441 |
# NOTE: no paren around UNION with sqlitebackend |
|
1442 |
for t in self._parse(( |
|
1443 |
||
1444 |
('Any N ORDERBY 1 WITH N BEING ' |
|
1445 |
'((Any N WHERE X name N, X is State)' |
|
1446 |
' UNION ' |
|
1447 |
'(Any NN WHERE XX name NN, XX is Transition))', |
|
1448 |
'''SELECT _T0.C0 |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1449 |
FROM (SELECT X.cw_name AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1450 |
FROM cw_State AS X |
0 | 1451 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1452 |
SELECT XX.cw_name AS C0 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1453 |
FROM cw_Transition AS XX) AS _T0 |
0 | 1454 |
ORDER BY 1'''), |
1455 |
||
1456 |
('Any N,NX ORDERBY NX WITH N,NX BEING ' |
|
1457 |
'((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
|
1458 |
' UNION ' |
|
1459 |
'(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
|
1460 |
'''SELECT _T0.C0, _T0.C1 |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1461 |
FROM (SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1462 |
FROM cw_State AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1463 |
GROUP BY X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1464 |
HAVING COUNT(X.cw_eid)>1 |
0 | 1465 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1466 |
SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1467 |
FROM cw_Transition AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1468 |
GROUP BY X.cw_name |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1469 |
HAVING COUNT(X.cw_eid)>1) AS _T0 |
0 | 1470 |
ORDER BY 2'''), |
1471 |
||
1472 |
('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
|
1473 |
'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
|
1474 |
' (Any X, N WHERE X name N, X is Transition))', |
|
1475 |
'''SELECT _T0.C1, COUNT(_T0.C0) |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1476 |
FROM (SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1477 |
FROM cw_State AS X |
0 | 1478 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1479 |
SELECT X.cw_eid AS C0, X.cw_name AS C1 |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1480 |
FROM cw_Transition AS X) AS _T0 |
0 | 1481 |
GROUP BY _T0.C1 |
1482 |
HAVING COUNT(_T0.C0)>1'''), |
|
1483 |
)): |
|
1484 |
yield t |
|
1485 |
||
1486 |
def test_has_text(self): |
|
1487 |
for t in self._parse(( |
|
1488 |
('Any X WHERE X has_text "toto tata"', |
|
1489 |
"""SELECT appears0.uid |
|
1490 |
FROM appears AS appears0 |
|
1491 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
|
1492 |
||
1493 |
('Any X WHERE X has_text %(text)s', |
|
1494 |
"""SELECT appears0.uid |
|
1495 |
FROM appears AS appears0 |
|
1496 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('hip', 'hop', 'momo'))"""), |
|
1497 |
||
1498 |
('Personne X WHERE X has_text "toto tata"', |
|
1499 |
"""SELECT X.eid |
|
1500 |
FROM appears AS appears0, entities AS X |
|
1501 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.eid AND X.type='Personne'"""), |
|
1502 |
||
1503 |
('Any X WHERE X has_text "toto tata", X name "tutu"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1504 |
"""SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1505 |
FROM appears AS appears0, cw_Basket AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1506 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1507 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1508 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1509 |
FROM appears AS appears0, cw_File AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1510 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1511 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1512 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1513 |
FROM appears AS appears0, cw_Folder AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1514 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1515 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1516 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1517 |
FROM appears AS appears0, cw_Image AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1518 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1519 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1520 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1521 |
FROM appears AS appears0, cw_State AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1522 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1523 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1524 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1525 |
FROM appears AS appears0, cw_Tag AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1526 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1527 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1528 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1529 |
FROM appears AS appears0, cw_Transition AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1530 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu"""), |
0 | 1531 |
)): |
1532 |
yield t |
|
1533 |
||
1534 |
||
1535 |
||
1536 |
class MySQLGenerator(PostgresSQLGeneratorTC): |
|
1537 |
||
1538 |
def setUp(self): |
|
1539 |
RQLGeneratorTC.setUp(self) |
|
1540 |
indexer = get_indexer('mysql', 'utf8') |
|
1541 |
dbms_helper = ADV_FUNC_HELPER_DIRECTORY['mysql'] |
|
1542 |
dbms_helper.fti_uid_attr = indexer.uid_attr |
|
1543 |
dbms_helper.fti_table = indexer.table |
|
1544 |
dbms_helper.fti_restriction_sql = indexer.restriction_sql |
|
1545 |
dbms_helper.fti_need_distinct_query = indexer.need_distinct |
|
1546 |
self.o = SQLGenerator(schema, dbms_helper) |
|
1547 |
||
1548 |
def _norm_sql(self, sql): |
|
1549 |
return sql.strip().replace(' ILIKE ', ' LIKE ') |
|
1550 |
||
1551 |
def test_from_clause_needed(self): |
|
1552 |
queries = [("Any 1 WHERE EXISTS(T is EGroup, T name 'managers')", |
|
1553 |
'''SELECT 1 |
|
1554 |
FROM (SELECT 1) AS _T |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1555 |
WHERE EXISTS(SELECT 1 FROM cw_EGroup AS T WHERE T.cw_name=managers)'''), |
0 | 1556 |
('Any X,Y WHERE NOT X created_by Y, X eid 5, Y eid 6', |
1557 |
'''SELECT 5, 6 |
|
1558 |
FROM (SELECT 1) AS _T |
|
1559 |
WHERE NOT EXISTS(SELECT 1 FROM created_by_relation AS rel_created_by0 WHERE rel_created_by0.eid_from=5 AND rel_created_by0.eid_to=6)'''), |
|
1560 |
] |
|
1561 |
for t in self._parse(queries): |
|
1562 |
yield t |
|
1563 |
||
1564 |
||
1565 |
def test_has_text(self): |
|
1566 |
queries = [ |
|
1567 |
('Any X WHERE X has_text "toto tata"', |
|
1568 |
"""SELECT appears0.uid |
|
1569 |
FROM appears AS appears0 |
|
1570 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE)"""), |
|
1571 |
('Personne X WHERE X has_text "toto tata"', |
|
1572 |
"""SELECT X.eid |
|
1573 |
FROM appears AS appears0, entities AS X |
|
1574 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.eid AND X.type='Personne'"""), |
|
1575 |
('Personne X WHERE X has_text %(text)s', |
|
1576 |
"""SELECT X.eid |
|
1577 |
FROM appears AS appears0, entities AS X |
|
1578 |
WHERE MATCH (appears0.words) AGAINST ('hip hop momo' IN BOOLEAN MODE) AND appears0.uid=X.eid AND X.type='Personne'"""), |
|
1579 |
('Any X WHERE X has_text "toto tata", X name "tutu"', |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1580 |
"""SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1581 |
FROM appears AS appears0, cw_Basket AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1582 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1583 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1584 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1585 |
FROM appears AS appears0, cw_File AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1586 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1587 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1588 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1589 |
FROM appears AS appears0, cw_Folder AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1590 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1591 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1592 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1593 |
FROM appears AS appears0, cw_Image AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1594 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1595 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1596 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1597 |
FROM appears AS appears0, cw_State AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1598 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1599 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1600 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1601 |
FROM appears AS appears0, cw_Tag AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1602 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
0 | 1603 |
UNION ALL |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1604 |
SELECT X.cw_eid |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1605 |
FROM appears AS appears0, cw_Transition AS X |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1606 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu""") |
0 | 1607 |
] |
1608 |
for t in self._parse(queries): |
|
1609 |
yield t |
|
1610 |
||
1611 |
||
1612 |
def test_ambigous_exists_no_from_clause(self): |
|
1613 |
self._check('Any COUNT(U) WHERE U eid 1, EXISTS (P owned_by U, P is IN (Note, Affaire))', |
|
1614 |
'''SELECT COUNT(1) |
|
1615 |
FROM (SELECT 1) AS _T |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
599
diff
changeset
|
1616 |
WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, cw_Affaire AS P WHERE rel_owned_by0.eid_from=P.cw_eid AND rel_owned_by0.eid_to=1 UNION SELECT 1 FROM owned_by_relation AS rel_owned_by1, cw_Note AS P WHERE rel_owned_by1.eid_from=P.cw_eid AND rel_owned_by1.eid_to=1)''') |
0 | 1617 |
|
1618 |
||
1619 |
||
1620 |
||
1621 |
if __name__ == '__main__': |
|
1622 |
unittest_main() |