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