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