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