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