43 BASIC = [ |
43 BASIC = [ |
44 |
44 |
45 ("Any X WHERE X is Affaire", |
45 ("Any X WHERE X is Affaire", |
46 '''SELECT X.cw_eid |
46 '''SELECT X.cw_eid |
47 FROM cw_Affaire AS X'''), |
47 FROM cw_Affaire AS X'''), |
48 |
48 |
49 ("Any X WHERE X eid 0", |
49 ("Any X WHERE X eid 0", |
50 '''SELECT 0'''), |
50 '''SELECT 0'''), |
51 |
51 |
52 ("Personne P", |
52 ("Personne P", |
53 '''SELECT P.cw_eid |
53 '''SELECT P.cw_eid |
54 FROM cw_Personne AS P'''), |
54 FROM cw_Personne AS P'''), |
55 |
55 |
56 ("Personne P WHERE P test TRUE", |
56 ("Personne P WHERE P test TRUE", |
57 '''SELECT P.cw_eid |
57 '''SELECT P.cw_eid |
58 FROM cw_Personne AS P |
58 FROM cw_Personne AS P |
59 WHERE P.cw_test=True'''), |
59 WHERE P.cw_test=TRUE'''), |
60 |
60 |
61 ("Personne P WHERE P test false", |
61 ("Personne P WHERE P test false", |
62 '''SELECT P.cw_eid |
62 '''SELECT P.cw_eid |
63 FROM cw_Personne AS P |
63 FROM cw_Personne AS P |
64 WHERE P.cw_test=False'''), |
64 WHERE P.cw_test=FALSE'''), |
65 |
65 |
66 ("Personne P WHERE P eid -1", |
66 ("Personne P WHERE P eid -1", |
67 '''SELECT -1'''), |
67 '''SELECT -1'''), |
68 |
68 |
69 ("Personne P LIMIT 20 OFFSET 10", |
69 ("Personne P LIMIT 20 OFFSET 10", |
158 |
158 |
159 ("Societe S WHERE S nom 'Logilab' OR S nom 'Caesium'", |
159 ("Societe S WHERE S nom 'Logilab' OR S nom 'Caesium'", |
160 '''SELECT S.cw_eid |
160 '''SELECT S.cw_eid |
161 FROM cw_Societe AS S |
161 FROM cw_Societe AS S |
162 WHERE ((S.cw_nom=Logilab) OR (S.cw_nom=Caesium))'''), |
162 WHERE ((S.cw_nom=Logilab) OR (S.cw_nom=Caesium))'''), |
163 |
163 |
164 ('Any X WHERE X nom "toto", X eid IN (9700, 9710, 1045, 674)', |
164 ('Any X WHERE X nom "toto", X eid IN (9700, 9710, 1045, 674)', |
165 '''SELECT X.cw_eid |
165 '''SELECT X.cw_eid |
166 FROM cw_Division AS X |
166 FROM cw_Division AS X |
167 WHERE X.cw_nom=toto AND X.cw_eid IN(9700, 9710, 1045, 674) |
167 WHERE X.cw_nom=toto AND X.cw_eid IN(9700, 9710, 1045, 674) |
168 UNION ALL |
168 UNION ALL |
205 |
205 |
206 ("Any N WHERE A evaluee N or N todo_by U", |
206 ("Any N WHERE A evaluee N or N todo_by U", |
207 '''SELECT N.cw_eid |
207 '''SELECT N.cw_eid |
208 FROM cw_Note AS N, evaluee_relation AS rel_evaluee0, todo_by_relation AS rel_todo_by1 |
208 FROM cw_Note AS N, evaluee_relation AS rel_evaluee0, todo_by_relation AS rel_todo_by1 |
209 WHERE ((rel_evaluee0.eid_to=N.cw_eid) OR (rel_todo_by1.eid_from=N.cw_eid))'''), |
209 WHERE ((rel_evaluee0.eid_to=N.cw_eid) OR (rel_todo_by1.eid_from=N.cw_eid))'''), |
210 |
210 |
211 ("Any X WHERE X concerne B or C concerne X, B eid 12, C eid 13", |
211 ("Any X WHERE X concerne B or C concerne X, B eid 12, C eid 13", |
212 '''SELECT X.cw_eid |
212 '''SELECT X.cw_eid |
213 FROM concerne_relation AS rel_concerne0, concerne_relation AS rel_concerne1, cw_Affaire AS X |
213 FROM concerne_relation AS rel_concerne0, concerne_relation AS rel_concerne1, cw_Affaire AS X |
214 WHERE ((rel_concerne0.eid_from=X.cw_eid AND rel_concerne0.eid_to=12) OR (rel_concerne1.eid_from=13 AND rel_concerne1.eid_to=X.cw_eid))'''), |
214 WHERE ((rel_concerne0.eid_from=X.cw_eid AND rel_concerne0.eid_to=12) OR (rel_concerne1.eid_from=13 AND rel_concerne1.eid_to=X.cw_eid))'''), |
215 |
215 |
224 WHERE ((rel_travaille_subdivision0.eid_from=P.cw_eid AND rel_travaille_subdivision0.eid_to=S1.cw_eid) OR (rel_travaille_subdivision1.eid_from=P.cw_eid AND rel_travaille_subdivision1.eid_to=S2.cw_eid)) AND S1.cw_nom=logilab AND S2.cw_nom=caesium'''), |
224 WHERE ((rel_travaille_subdivision0.eid_from=P.cw_eid AND rel_travaille_subdivision0.eid_to=S1.cw_eid) OR (rel_travaille_subdivision1.eid_from=P.cw_eid AND rel_travaille_subdivision1.eid_to=S2.cw_eid)) AND S1.cw_nom=logilab AND S2.cw_nom=caesium'''), |
225 |
225 |
226 ('Any X WHERE T tags X', |
226 ('Any X WHERE T tags X', |
227 '''SELECT rel_tags0.eid_to |
227 '''SELECT rel_tags0.eid_to |
228 FROM tags_relation AS rel_tags0'''), |
228 FROM tags_relation AS rel_tags0'''), |
229 |
229 |
230 ('Any X WHERE X in_basket B, B eid 12', |
230 ('Any X WHERE X in_basket B, B eid 12', |
231 '''SELECT rel_in_basket0.eid_from |
231 '''SELECT rel_in_basket0.eid_from |
232 FROM in_basket_relation AS rel_in_basket0 |
232 FROM in_basket_relation AS rel_in_basket0 |
233 WHERE rel_in_basket0.eid_to=12'''), |
233 WHERE rel_in_basket0.eid_to=12'''), |
234 |
234 |
235 ('Any SEN,RN,OEN WHERE X from_entity SE, SE eid 44, X relation_type R, R eid 139, X to_entity OE, OE eid 42, R name RN, SE name SEN, OE name OEN', |
235 ('Any SEN,RN,OEN WHERE X from_entity SE, SE eid 44, X relation_type R, R eid 139, X to_entity OE, OE eid 42, R name RN, SE name SEN, OE name OEN', |
236 '''SELECT SE.cw_name, R.cw_name, OE.cw_name |
236 '''SELECT SE.cw_name, R.cw_name, OE.cw_name |
237 FROM cw_CWEType AS OE, cw_CWEType AS SE, cw_CWAttribute AS X, cw_CWRType AS R |
237 FROM cw_CWAttribute AS X, cw_CWEType AS OE, cw_CWEType AS SE, cw_CWRType AS R |
238 WHERE X.cw_from_entity=44 AND SE.cw_eid=44 AND X.cw_relation_type=139 AND R.cw_eid=139 AND X.cw_to_entity=42 AND OE.cw_eid=42 |
238 WHERE X.cw_from_entity=44 AND SE.cw_eid=44 AND X.cw_relation_type=139 AND R.cw_eid=139 AND X.cw_to_entity=42 AND OE.cw_eid=42 |
239 UNION ALL |
239 UNION ALL |
240 SELECT SE.cw_name, R.cw_name, OE.cw_name |
240 SELECT SE.cw_name, R.cw_name, OE.cw_name |
241 FROM cw_CWEType AS OE, cw_CWEType AS SE, cw_CWRelation AS X, cw_CWRType AS R |
241 FROM cw_CWEType AS OE, cw_CWEType AS SE, cw_CWRType AS R, cw_CWRelation AS X |
242 WHERE X.cw_from_entity=44 AND SE.cw_eid=44 AND X.cw_relation_type=139 AND R.cw_eid=139 AND X.cw_to_entity=42 AND OE.cw_eid=42'''), |
242 WHERE X.cw_from_entity=44 AND SE.cw_eid=44 AND X.cw_relation_type=139 AND R.cw_eid=139 AND X.cw_to_entity=42 AND OE.cw_eid=42'''), |
243 |
243 |
244 # Any O WHERE NOT S corrected_in O, S eid %(x)s, S concerns P, O version_of P, O in_state ST, NOT ST name "published", O modification_date MTIME ORDERBY MTIME DESC LIMIT 9 |
244 # Any O WHERE NOT S corrected_in O, S eid %(x)s, S concerns P, O version_of P, O in_state ST, NOT ST name "published", O modification_date MTIME ORDERBY MTIME DESC LIMIT 9 |
245 ('Any O WHERE NOT S ecrit_par O, S eid 1, S inline1 P, O inline2 P', |
245 ('Any O WHERE NOT S ecrit_par O, S eid 1, S inline1 P, O inline2 P', |
246 '''SELECT DISTINCT O.cw_eid |
246 '''SELECT DISTINCT O.cw_eid |
262 ('Any N WHERE N todo_by U, U eid 2, P evaluee N, P eid 3', |
262 ('Any N WHERE N todo_by U, U eid 2, P evaluee N, P eid 3', |
263 '''SELECT rel_evaluee1.eid_to |
263 '''SELECT rel_evaluee1.eid_to |
264 FROM evaluee_relation AS rel_evaluee1, todo_by_relation AS rel_todo_by0 |
264 FROM evaluee_relation AS rel_evaluee1, todo_by_relation AS rel_todo_by0 |
265 WHERE rel_evaluee1.eid_to=rel_todo_by0.eid_from AND rel_todo_by0.eid_to=2 AND rel_evaluee1.eid_from=3'''), |
265 WHERE rel_evaluee1.eid_to=rel_todo_by0.eid_from AND rel_todo_by0.eid_to=2 AND rel_evaluee1.eid_from=3'''), |
266 |
266 |
267 |
267 |
268 (' Any X,U WHERE C owned_by U, NOT X owned_by U, C eid 1, X eid 2', |
268 (' Any X,U WHERE C owned_by U, NOT X owned_by U, C eid 1, X eid 2', |
269 '''SELECT 2, rel_owned_by0.eid_to |
269 '''SELECT 2, rel_owned_by0.eid_to |
270 FROM owned_by_relation AS rel_owned_by0 |
270 FROM owned_by_relation AS rel_owned_by0 |
271 WHERE rel_owned_by0.eid_from=1 AND NOT EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by1 WHERE rel_owned_by1.eid_from=2 AND rel_owned_by0.eid_to=rel_owned_by1.eid_to)'''), |
271 WHERE rel_owned_by0.eid_from=1 AND NOT EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by1 WHERE rel_owned_by1.eid_from=2 AND rel_owned_by0.eid_to=rel_owned_by1.eid_to)'''), |
272 |
272 |
277 |
277 |
278 ('Any C WHERE C is Card, EXISTS(X documented_by C)', |
278 ('Any C WHERE C is Card, EXISTS(X documented_by C)', |
279 """SELECT C.cw_eid |
279 """SELECT C.cw_eid |
280 FROM cw_Card AS C |
280 FROM cw_Card AS C |
281 WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_to=C.cw_eid)"""), |
281 WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_to=C.cw_eid)"""), |
282 |
282 |
283 ('Any C WHERE C is Card, EXISTS(X documented_by C, X eid 12)', |
283 ('Any C WHERE C is Card, EXISTS(X documented_by C, X eid 12)', |
284 """SELECT C.cw_eid |
284 """SELECT C.cw_eid |
285 FROM cw_Card AS C |
285 FROM cw_Card AS C |
286 WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_from=12 AND rel_documented_by0.eid_to=C.cw_eid)"""), |
286 WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_from=12 AND rel_documented_by0.eid_to=C.cw_eid)"""), |
287 |
287 |
321 |
321 |
322 ('Any L WHERE X login "admin", NOT X identity Y, Y login L', |
322 ('Any L WHERE X login "admin", NOT X identity Y, Y login L', |
323 '''SELECT Y.cw_login |
323 '''SELECT Y.cw_login |
324 FROM cw_CWUser AS X, cw_CWUser AS Y |
324 FROM cw_CWUser AS X, cw_CWUser AS Y |
325 WHERE X.cw_login=admin AND NOT X.cw_eid=Y.cw_eid'''), |
325 WHERE X.cw_login=admin AND NOT X.cw_eid=Y.cw_eid'''), |
326 |
326 |
327 ('Any L WHERE X login "admin", X identity Y?, Y login L', |
327 ('Any L WHERE X login "admin", X identity Y?, Y login L', |
328 '''SELECT Y.cw_login |
328 '''SELECT Y.cw_login |
329 FROM cw_CWUser AS X LEFT OUTER JOIN cw_CWUser AS Y ON (X.cw_eid=Y.cw_eid) |
329 FROM cw_CWUser AS X LEFT OUTER JOIN cw_CWUser AS Y ON (X.cw_eid=Y.cw_eid) |
330 WHERE X.cw_login=admin'''), |
330 WHERE X.cw_login=admin'''), |
331 |
331 |
436 WHERE X.cw_name=CWGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
436 WHERE X.cw_name=CWGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
437 UNION |
437 UNION |
438 SELECT DISTINCT X.cw_eid, Y.cw_eid |
438 SELECT DISTINCT X.cw_eid, Y.cw_eid |
439 FROM cw_CWRType AS X, cw_RQLExpression AS Y |
439 FROM cw_CWRType AS X, cw_RQLExpression AS Y |
440 WHERE X.cw_name=CWGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid)'''), |
440 WHERE X.cw_name=CWGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid)'''), |
441 |
441 |
442 # neged relation, can't be inveriant |
442 # neged relation, can't be inveriant |
443 ('Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT X read_permission Y', |
443 ('Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT X read_permission Y', |
444 '''SELECT X.cw_eid, Y.cw_eid |
444 '''SELECT X.cw_eid, Y.cw_eid |
445 FROM cw_CWEType AS X, cw_CWGroup AS Y |
445 FROM cw_CWEType AS X, cw_CWGroup AS Y |
446 WHERE X.cw_name=CWGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
446 WHERE X.cw_name=CWGroup AND Y.cw_eid IN(1, 2, 3) AND NOT EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=X.cw_eid AND rel_read_permission0.eid_to=Y.cw_eid) |
495 FROM cw_Tag AS X |
495 FROM cw_Tag AS X |
496 UNION ALL |
496 UNION ALL |
497 SELECT X.cw_eid AS C0, X.cw_name AS C1 |
497 SELECT X.cw_eid AS C0, X.cw_name AS C1 |
498 FROM cw_Transition AS X) AS T1 |
498 FROM cw_Transition AS X) AS T1 |
499 GROUP BY T1.C1'''), |
499 GROUP BY T1.C1'''), |
500 |
500 |
501 ('Any MAX(X)+MIN(LENGTH(D)), N GROUPBY N ORDERBY 1, N, DF WHERE X name N, X data D, X data_format DF;', |
501 ('Any MAX(X)+MIN(LENGTH(D)), N GROUPBY N ORDERBY 1, N, DF WHERE X name N, X data D, X data_format DF;', |
502 '''SELECT (MAX(T1.C1) + MIN(LENGTH(T1.C0))), T1.C2 FROM (SELECT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
502 '''SELECT (MAX(T1.C1) + MIN(LENGTH(T1.C0))), T1.C2 FROM (SELECT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
503 FROM cw_File AS X |
503 FROM cw_File AS X |
504 UNION ALL |
504 UNION ALL |
505 SELECT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
505 SELECT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
509 |
509 |
510 ('DISTINCT Any S ORDERBY R WHERE A is Affaire, A sujet S, A ref R', |
510 ('DISTINCT Any S ORDERBY R WHERE A is Affaire, A sujet S, A ref R', |
511 '''SELECT T1.C0 FROM (SELECT DISTINCT A.cw_sujet AS C0, A.cw_ref AS C1 |
511 '''SELECT T1.C0 FROM (SELECT DISTINCT A.cw_sujet AS C0, A.cw_ref AS C1 |
512 FROM cw_Affaire AS A |
512 FROM cw_Affaire AS A |
513 ORDER BY 2) AS T1'''), |
513 ORDER BY 2) AS T1'''), |
514 |
514 |
515 ('DISTINCT Any MAX(X)+MIN(LENGTH(D)), N GROUPBY N ORDERBY 2, DF WHERE X name N, X data D, X data_format DF;', |
515 ('DISTINCT Any MAX(X)+MIN(LENGTH(D)), N GROUPBY N ORDERBY 2, DF WHERE X name N, X data D, X data_format DF;', |
516 '''SELECT T1.C0,T1.C1 FROM (SELECT DISTINCT (MAX(T1.C1) + MIN(LENGTH(T1.C0))) AS C0, T1.C2 AS C1, T1.C3 AS C2 FROM (SELECT DISTINCT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
516 '''SELECT T1.C0,T1.C1 FROM (SELECT DISTINCT (MAX(T1.C1) + MIN(LENGTH(T1.C0))) AS C0, T1.C2 AS C1, T1.C3 AS C2 FROM (SELECT DISTINCT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
517 FROM cw_File AS X |
517 FROM cw_File AS X |
518 UNION |
518 UNION |
519 SELECT DISTINCT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
519 SELECT DISTINCT X.cw_data AS C0, X.cw_eid AS C1, X.cw_name AS C2, X.cw_data_format AS C3 |
526 ('Any T WHERE T is Tag, NOT T name in ("t1", "t2"), EXISTS(T tags X, X is IN (CWUser, CWGroup))', |
526 ('Any T WHERE T is Tag, NOT T name in ("t1", "t2"), EXISTS(T tags X, X is IN (CWUser, CWGroup))', |
527 '''SELECT T.cw_eid |
527 '''SELECT T.cw_eid |
528 FROM cw_Tag AS T |
528 FROM cw_Tag AS T |
529 WHERE NOT (T.cw_name IN(t1, t2)) AND EXISTS(SELECT 1 FROM tags_relation AS rel_tags0, cw_CWGroup AS X WHERE rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=X.cw_eid UNION SELECT 1 FROM tags_relation AS rel_tags1, cw_CWUser AS X WHERE rel_tags1.eid_from=T.cw_eid AND rel_tags1.eid_to=X.cw_eid)'''), |
529 WHERE NOT (T.cw_name IN(t1, t2)) AND EXISTS(SELECT 1 FROM tags_relation AS rel_tags0, cw_CWGroup AS X WHERE rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=X.cw_eid UNION SELECT 1 FROM tags_relation AS rel_tags1, cw_CWUser AS X WHERE rel_tags1.eid_from=T.cw_eid AND rel_tags1.eid_to=X.cw_eid)'''), |
530 |
530 |
531 # must not use a relation in EXISTS scope to inline a variable |
531 # must not use a relation in EXISTS scope to inline a variable |
532 ('Any U WHERE U eid IN (1,2), EXISTS(X owned_by U)', |
532 ('Any U WHERE U eid IN (1,2), EXISTS(X owned_by U)', |
533 '''SELECT U.cw_eid |
533 '''SELECT U.cw_eid |
534 FROM cw_CWUser AS U |
534 FROM cw_CWUser AS U |
535 WHERE U.cw_eid IN(1, 2) AND EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_to=U.cw_eid)'''), |
535 WHERE U.cw_eid IN(1, 2) AND EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_to=U.cw_eid)'''), |
536 |
536 |
549 FROM entities AS X'''), |
549 FROM entities AS X'''), |
550 |
550 |
551 ('Any MAX(X) WHERE X is Note', |
551 ('Any MAX(X) WHERE X is Note', |
552 '''SELECT MAX(X.cw_eid) |
552 '''SELECT MAX(X.cw_eid) |
553 FROM cw_Note AS X'''), |
553 FROM cw_Note AS X'''), |
554 |
554 |
555 ('Any X WHERE X eid > 12', |
555 ('Any X WHERE X eid > 12', |
556 '''SELECT X.eid |
556 '''SELECT X.eid |
557 FROM entities AS X |
557 FROM entities AS X |
558 WHERE X.eid>12'''), |
558 WHERE X.eid>12'''), |
559 |
559 |
560 ('Any X WHERE X eid > 12, X is Note', |
560 ('Any X WHERE X eid > 12, X is Note', |
561 """SELECT X.eid |
561 """SELECT X.eid |
562 FROM entities AS X |
562 FROM entities AS X |
563 WHERE X.type='Note' AND X.eid>12"""), |
563 WHERE X.type='Note' AND X.eid>12"""), |
564 |
564 |
565 ('Any X, T WHERE X eid > 12, X title T', |
565 ('Any X, T WHERE X eid > 12, X title T', |
566 """SELECT X.cw_eid, X.cw_title |
566 """SELECT X.cw_eid, X.cw_title |
567 FROM cw_Bookmark AS X |
567 FROM cw_Bookmark AS X |
568 WHERE X.cw_eid>12 |
568 WHERE X.cw_eid>12 |
569 UNION ALL |
569 UNION ALL |
579 '''SELECT X.eid |
579 '''SELECT X.eid |
580 FROM entities AS X'''), |
580 FROM entities AS X'''), |
581 |
581 |
582 ('Any X GROUPBY X WHERE X eid 12', |
582 ('Any X GROUPBY X WHERE X eid 12', |
583 '''SELECT 12'''), |
583 '''SELECT 12'''), |
584 |
584 |
585 ('Any X GROUPBY X ORDERBY Y WHERE X eid 12, X login Y', |
585 ('Any X GROUPBY X ORDERBY Y WHERE X eid 12, X login Y', |
586 '''SELECT X.cw_eid |
586 '''SELECT X.cw_eid |
587 FROM cw_CWUser AS X |
587 FROM cw_CWUser AS X |
588 WHERE X.cw_eid=12 |
588 WHERE X.cw_eid=12 |
589 GROUP BY X.cw_eid |
589 GROUP BY X.cw_eid |
590 ORDER BY X.cw_login'''), |
590 ORDER BY X.cw_login'''), |
591 |
591 |
592 ('Any U,COUNT(X) GROUPBY U WHERE U eid 12, X owned_by U HAVING COUNT(X) > 10', |
592 ('Any U,COUNT(X) GROUPBY U WHERE U eid 12, X owned_by U HAVING COUNT(X) > 10', |
593 '''SELECT rel_owned_by0.eid_to, COUNT(rel_owned_by0.eid_from) |
593 '''SELECT rel_owned_by0.eid_to, COUNT(rel_owned_by0.eid_from) |
594 FROM owned_by_relation AS rel_owned_by0 |
594 FROM owned_by_relation AS rel_owned_by0 |
595 WHERE rel_owned_by0.eid_to=12 |
595 WHERE rel_owned_by0.eid_to=12 |
596 GROUP BY rel_owned_by0.eid_to |
596 GROUP BY rel_owned_by0.eid_to |
598 |
598 |
599 ('DISTINCT Any X ORDERBY stockproc(X) WHERE U login X', |
599 ('DISTINCT Any X ORDERBY stockproc(X) WHERE U login X', |
600 '''SELECT T1.C0 FROM (SELECT DISTINCT U.cw_login AS C0, STOCKPROC(U.cw_login) AS C1 |
600 '''SELECT T1.C0 FROM (SELECT DISTINCT U.cw_login AS C0, STOCKPROC(U.cw_login) AS C1 |
601 FROM cw_CWUser AS U |
601 FROM cw_CWUser AS U |
602 ORDER BY 2) AS T1'''), |
602 ORDER BY 2) AS T1'''), |
603 |
603 |
604 ('DISTINCT Any X ORDERBY Y WHERE B bookmarked_by X, X login Y', |
604 ('DISTINCT Any X ORDERBY Y WHERE B bookmarked_by X, X login Y', |
605 '''SELECT T1.C0 FROM (SELECT DISTINCT X.cw_eid AS C0, X.cw_login AS C1 |
605 '''SELECT T1.C0 FROM (SELECT DISTINCT X.cw_eid AS C0, X.cw_login AS C1 |
606 FROM bookmarked_by_relation AS rel_bookmarked_by0, cw_CWUser AS X |
606 FROM bookmarked_by_relation AS rel_bookmarked_by0, cw_CWUser AS X |
607 WHERE rel_bookmarked_by0.eid_to=X.cw_eid |
607 WHERE rel_bookmarked_by0.eid_to=X.cw_eid |
608 ORDER BY 2) AS T1'''), |
608 ORDER BY 2) AS T1'''), |
640 NEGATIONS = [ |
640 NEGATIONS = [ |
641 ("Personne X WHERE NOT X evaluee Y;", |
641 ("Personne X WHERE NOT X evaluee Y;", |
642 '''SELECT X.cw_eid |
642 '''SELECT X.cw_eid |
643 FROM cw_Personne AS X |
643 FROM cw_Personne AS X |
644 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=X.cw_eid)'''), |
644 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=X.cw_eid)'''), |
645 |
645 |
646 ("Note N WHERE NOT X evaluee N, X eid 0", |
646 ("Note N WHERE NOT X evaluee N, X eid 0", |
647 '''SELECT N.cw_eid |
647 '''SELECT N.cw_eid |
648 FROM cw_Note AS N |
648 FROM cw_Note AS N |
649 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=0 AND rel_evaluee0.eid_to=N.cw_eid)'''), |
649 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=0 AND rel_evaluee0.eid_to=N.cw_eid)'''), |
650 |
650 |
651 ('Any X WHERE NOT X travaille S, X is Personne', |
651 ('Any X WHERE NOT X travaille S, X is Personne', |
652 '''SELECT X.cw_eid |
652 '''SELECT X.cw_eid |
653 FROM cw_Personne AS X |
653 FROM cw_Personne AS X |
654 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid)'''), |
654 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid)'''), |
655 |
655 |
656 ("Personne P where not P datenaiss TODAY", |
656 ("Personne P where not P datenaiss TODAY", |
657 '''SELECT P.cw_eid |
657 '''SELECT P.cw_eid |
658 FROM cw_Personne AS P |
658 FROM cw_Personne AS P |
659 WHERE NOT (DATE(P.cw_datenaiss)=CURRENT_DATE)'''), |
659 WHERE NOT (DATE(P.cw_datenaiss)=CURRENT_DATE)'''), |
660 |
660 |
661 ("Personne P where NOT P concerne A", |
661 ("Personne P where NOT P concerne A", |
662 '''SELECT P.cw_eid |
662 '''SELECT P.cw_eid |
663 FROM cw_Personne AS P |
663 FROM cw_Personne AS P |
664 WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_from=P.cw_eid)'''), |
664 WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_from=P.cw_eid)'''), |
665 |
665 |
666 ("Affaire A where not P concerne A", |
666 ("Affaire A where not P concerne A", |
667 '''SELECT A.cw_eid |
667 '''SELECT A.cw_eid |
668 FROM cw_Affaire AS A |
668 FROM cw_Affaire AS A |
669 WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_to=A.cw_eid)'''), |
669 WHERE NOT EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_to=A.cw_eid)'''), |
670 ("Personne P where not P concerne A, A sujet ~= 'TEST%'", |
670 ("Personne P where not P concerne A, A sujet ~= 'TEST%'", |
674 |
674 |
675 ('Any S WHERE NOT T eid 28258, T tags S', |
675 ('Any S WHERE NOT T eid 28258, T tags S', |
676 '''SELECT rel_tags0.eid_to |
676 '''SELECT rel_tags0.eid_to |
677 FROM tags_relation AS rel_tags0 |
677 FROM tags_relation AS rel_tags0 |
678 WHERE NOT (rel_tags0.eid_from=28258)'''), |
678 WHERE NOT (rel_tags0.eid_from=28258)'''), |
679 |
679 |
680 ('Any S WHERE T is Tag, T name TN, NOT T eid 28258, T tags S, S name SN', |
680 ('Any S WHERE T is Tag, T name TN, NOT T eid 28258, T tags S, S name SN', |
681 '''SELECT S.cw_eid |
681 '''SELECT S.cw_eid |
682 FROM cw_CWGroup AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
682 FROM cw_CWGroup AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
683 WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid |
683 WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid |
684 UNION ALL |
684 UNION ALL |
688 UNION ALL |
688 UNION ALL |
689 SELECT S.cw_eid |
689 SELECT S.cw_eid |
690 FROM cw_Tag AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
690 FROM cw_Tag AS S, cw_Tag AS T, tags_relation AS rel_tags0 |
691 WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid'''), |
691 WHERE NOT (T.cw_eid=28258) AND rel_tags0.eid_from=T.cw_eid AND rel_tags0.eid_to=S.cw_eid'''), |
692 |
692 |
693 |
693 |
694 ('Any X,Y WHERE X created_by Y, X eid 5, NOT Y eid 6', |
694 ('Any X,Y WHERE X created_by Y, X eid 5, NOT Y eid 6', |
695 '''SELECT 5, rel_created_by0.eid_to |
695 '''SELECT 5, rel_created_by0.eid_to |
696 FROM created_by_relation AS rel_created_by0 |
696 FROM created_by_relation AS rel_created_by0 |
697 WHERE rel_created_by0.eid_from=5 AND NOT (rel_created_by0.eid_to=6)'''), |
697 WHERE rel_created_by0.eid_from=5 AND NOT (rel_created_by0.eid_to=6)'''), |
698 |
698 |
701 FROM cw_Note AS X |
701 FROM cw_Note AS X |
702 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_to=X.cw_eid)'''), |
702 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_to=X.cw_eid)'''), |
703 |
703 |
704 ('Any Y WHERE NOT Y evaluee X', |
704 ('Any Y WHERE NOT Y evaluee X', |
705 '''SELECT Y.cw_eid |
705 '''SELECT Y.cw_eid |
|
706 FROM cw_CWUser AS Y |
|
707 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
|
708 UNION ALL |
|
709 SELECT Y.cw_eid |
706 FROM cw_Division AS Y |
710 FROM cw_Division AS Y |
707 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
|
708 UNION ALL |
|
709 SELECT Y.cw_eid |
|
710 FROM cw_CWUser AS Y |
|
711 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
711 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
712 UNION ALL |
712 UNION ALL |
713 SELECT Y.cw_eid |
713 SELECT Y.cw_eid |
714 FROM cw_Personne AS Y |
714 FROM cw_Personne AS Y |
715 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
715 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=Y.cw_eid) |
724 |
724 |
725 ('Any X WHERE NOT Y evaluee X, Y is CWUser', |
725 ('Any X WHERE NOT Y evaluee X, Y is CWUser', |
726 '''SELECT X.cw_eid |
726 '''SELECT X.cw_eid |
727 FROM cw_Note AS X |
727 FROM cw_Note AS X |
728 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0,cw_CWUser AS Y WHERE rel_evaluee0.eid_from=Y.cw_eid AND rel_evaluee0.eid_to=X.cw_eid)'''), |
728 WHERE NOT EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0,cw_CWUser AS Y WHERE rel_evaluee0.eid_from=Y.cw_eid AND rel_evaluee0.eid_to=X.cw_eid)'''), |
729 |
729 |
730 ('Any X,T WHERE X title T, NOT X is Bookmark', |
730 ('Any X,T WHERE X title T, NOT X is Bookmark', |
731 '''SELECT DISTINCT X.cw_eid, X.cw_title |
731 '''SELECT DISTINCT X.cw_eid, X.cw_title |
732 FROM cw_Card AS X |
732 FROM cw_Card AS X |
733 UNION |
733 UNION |
734 SELECT DISTINCT X.cw_eid, X.cw_title |
734 SELECT DISTINCT X.cw_eid, X.cw_title |
814 #FROM cw_Personne AS X LEFT OUTER JOIN connait_relation AS rel_connait0 ON (rel_connait0.eid_to=12) LEFT OUTER JOIN Personne AS P ON (rel_connait0.eid_from=P.cw_eid) |
814 #FROM cw_Personne AS X LEFT OUTER JOIN connait_relation AS rel_connait0 ON (rel_connait0.eid_to=12) LEFT OUTER JOIN Personne AS P ON (rel_connait0.eid_from=P.cw_eid) |
815 #WHERE X.cw_eid=12''' |
815 #WHERE X.cw_eid=12''' |
816 ), |
816 ), |
817 |
817 |
818 ('Any GN, TN ORDERBY GN WHERE T tags G?, T name TN, G name GN', |
818 ('Any GN, TN ORDERBY GN WHERE T tags G?, T name TN, G name GN', |
819 '''SELECT _T0.C1, T.cw_name |
819 ''' |
|
820 SELECT _T0.C1, T.cw_name |
820 FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN (SELECT G.cw_eid AS C0, G.cw_name AS C1 |
821 FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN (SELECT G.cw_eid AS C0, G.cw_name AS C1 |
821 FROM cw_CWGroup AS G |
822 FROM cw_CWGroup AS G |
822 UNION ALL |
823 UNION ALL |
823 SELECT G.cw_eid AS C0, G.cw_name AS C1 |
824 SELECT G.cw_eid AS C0, G.cw_name AS C1 |
824 FROM cw_State AS G |
825 FROM cw_State AS G |
864 |
865 |
865 # two optional variables with additional restriction on an inlined relation |
866 # two optional variables with additional restriction on an inlined relation |
866 ('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop", G is CWUser', |
867 ('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop", G is CWUser', |
867 '''SELECT T.cw_eid, G.cw_eid, S.cw_eid |
868 '''SELECT T.cw_eid, G.cw_eid, S.cw_eid |
868 FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_CWUser AS G ON (rel_tags0.eid_to=G.cw_eid) LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop)'''), |
869 FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN cw_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)'''), |
869 |
870 |
870 # two optional variables with additional restriction on an ambigous inlined relation |
871 # two optional variables with additional restriction on an ambigous inlined relation |
871 ('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop"', |
872 ('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop"', |
872 '''SELECT T.cw_eid, _T0.C0, _T0.C1 |
873 ''' |
|
874 SELECT T.cw_eid, _T0.C0, _T0.C1 |
873 FROM cw_Tag AS T LEFT OUTER JOIN tags_relation AS rel_tags0 ON (rel_tags0.eid_from=T.cw_eid) LEFT OUTER JOIN (SELECT G.cw_eid AS C0, S.cw_eid AS C1 |
875 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 |
874 FROM cw_Affaire AS G LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop) |
876 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) |
875 UNION ALL |
877 UNION ALL |
876 SELECT G.cw_eid AS C0, S.cw_eid AS C1 |
878 SELECT G.cw_eid AS C0, S.cw_eid AS C1 |
877 FROM cw_CWUser AS G LEFT OUTER JOIN cw_State AS S ON (G.cw_in_state=S.cw_eid AND S.cw_name=hop) |
879 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) |
884 VIRTUAL_VARS = [ |
886 VIRTUAL_VARS = [ |
885 ("Personne P WHERE P travaille S, S tel T, S fax T, S is Societe;", |
887 ("Personne P WHERE P travaille S, S tel T, S fax T, S is Societe;", |
886 '''SELECT rel_travaille0.eid_from |
888 '''SELECT rel_travaille0.eid_from |
887 FROM cw_Societe AS S, travaille_relation AS rel_travaille0 |
889 FROM cw_Societe AS S, travaille_relation AS rel_travaille0 |
888 WHERE rel_travaille0.eid_to=S.cw_eid AND S.cw_fax=S.cw_tel'''), |
890 WHERE rel_travaille0.eid_to=S.cw_eid AND S.cw_fax=S.cw_tel'''), |
889 |
891 |
890 ("Personne P where X eid 0, X creation_date D, P datenaiss < D, X is Affaire", |
892 ("Personne P where X eid 0, X creation_date D, P datenaiss < D, X is Affaire", |
891 '''SELECT P.cw_eid |
893 '''SELECT P.cw_eid |
892 FROM cw_Affaire AS X, cw_Personne AS P |
894 FROM cw_Affaire AS X, cw_Personne AS P |
893 WHERE X.cw_eid=0 AND P.cw_datenaiss<X.cw_creation_date'''), |
895 WHERE X.cw_eid=0 AND P.cw_datenaiss<X.cw_creation_date'''), |
894 |
896 |
957 # UNION |
959 # UNION |
958 # SELECT rel_connait0.eid_from |
960 # SELECT rel_connait0.eid_from |
959 # FROM connait_relation AS rel_connait0 |
961 # FROM connait_relation AS rel_connait0 |
960 # WHERE rel_connait0.eid_to=0''' |
962 # WHERE rel_connait0.eid_to=0''' |
961 ), |
963 ), |
962 |
964 |
963 ('Any P WHERE X connait P', |
965 ('Any P WHERE X connait P', |
964 '''SELECT DISTINCT P.cw_eid |
966 '''SELECT DISTINCT P.cw_eid |
965 FROM connait_relation AS rel_connait0, cw_Personne AS P |
967 FROM connait_relation AS rel_connait0, cw_Personne AS P |
966 WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid)''' |
968 WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid)''' |
967 ), |
969 ), |
968 |
970 |
969 ('Any X WHERE X connait P', |
971 ('Any X WHERE X connait P', |
970 '''SELECT DISTINCT X.cw_eid |
972 '''SELECT DISTINCT X.cw_eid |
971 FROM connait_relation AS rel_connait0, cw_Personne AS X |
973 FROM connait_relation AS rel_connait0, cw_Personne AS X |
972 WHERE (rel_connait0.eid_from=X.cw_eid OR rel_connait0.eid_to=X.cw_eid)''' |
974 WHERE (rel_connait0.eid_from=X.cw_eid OR rel_connait0.eid_to=X.cw_eid)''' |
973 ), |
975 ), |
974 |
976 |
975 ('Any P WHERE X eid 0, NOT X connait P', |
977 ('Any P WHERE X eid 0, NOT X connait P', |
976 '''SELECT P.cw_eid |
978 '''SELECT P.cw_eid |
977 FROM cw_Personne AS P |
979 FROM cw_Personne AS P |
978 WHERE NOT EXISTS(SELECT 1 FROM connait_relation AS rel_connait0 WHERE (rel_connait0.eid_from=0 AND rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_to=0 AND rel_connait0.eid_from=P.cw_eid))'''), |
980 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))'''), |
979 |
981 |
980 ('Any P WHERE NOT X connait P', |
982 ('Any P WHERE NOT X connait P', |
981 '''SELECT P.cw_eid |
983 '''SELECT P.cw_eid |
982 FROM cw_Personne AS P |
984 FROM cw_Personne AS P |
983 WHERE NOT EXISTS(SELECT 1 FROM connait_relation AS rel_connait0 WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid))'''), |
985 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))'''), |
984 |
986 |
985 ('Any X WHERE NOT X connait P', |
987 ('Any X WHERE NOT X connait P', |
986 '''SELECT X.cw_eid |
988 '''SELECT X.cw_eid |
987 FROM cw_Personne AS X |
989 FROM cw_Personne AS X |
988 WHERE NOT EXISTS(SELECT 1 FROM connait_relation AS rel_connait0 WHERE (rel_connait0.eid_from=X.cw_eid OR rel_connait0.eid_to=X.cw_eid))'''), |
990 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))'''), |
989 |
991 |
990 ('Any P WHERE X connait P, P nom "nom"', |
992 ('Any P WHERE X connait P, P nom "nom"', |
991 '''SELECT DISTINCT P.cw_eid |
993 '''SELECT DISTINCT P.cw_eid |
992 FROM connait_relation AS rel_connait0, cw_Personne AS P |
994 FROM connait_relation AS rel_connait0, cw_Personne AS P |
993 WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid) AND P.cw_nom=nom'''), |
995 WHERE (rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_from=P.cw_eid) AND P.cw_nom=nom'''), |
994 |
996 |
995 ('Any X WHERE X connait P, P nom "nom"', |
997 ('Any X WHERE X connait P, P nom "nom"', |
996 '''SELECT DISTINCT X.cw_eid |
998 '''SELECT DISTINCT X.cw_eid |
997 FROM connait_relation AS rel_connait0, cw_Personne AS P, cw_Personne AS X |
999 FROM connait_relation AS rel_connait0, cw_Personne AS P, cw_Personne AS X |
998 WHERE (rel_connait0.eid_from=X.cw_eid AND rel_connait0.eid_to=P.cw_eid OR rel_connait0.eid_to=X.cw_eid AND rel_connait0.eid_from=P.cw_eid) AND P.cw_nom=nom''' |
1000 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''' |
999 ), |
1001 ), |
1016 INLINE = [ |
1018 INLINE = [ |
1017 ('Any P, L WHERE N ecrit_par P, P nom L, N eid 0', |
1019 ('Any P, L WHERE N ecrit_par P, P nom L, N eid 0', |
1018 '''SELECT P.cw_eid, P.cw_nom |
1020 '''SELECT P.cw_eid, P.cw_nom |
1019 FROM cw_Note AS N, cw_Personne AS P |
1021 FROM cw_Note AS N, cw_Personne AS P |
1020 WHERE N.cw_ecrit_par=P.cw_eid AND N.cw_eid=0'''), |
1022 WHERE N.cw_ecrit_par=P.cw_eid AND N.cw_eid=0'''), |
1021 |
1023 |
1022 ('Any N WHERE NOT N ecrit_par P, P nom "toto"', |
1024 ('Any N WHERE NOT N ecrit_par P, P nom "toto"', |
1023 '''SELECT DISTINCT N.cw_eid |
1025 '''SELECT DISTINCT N.cw_eid |
1024 FROM cw_Note AS N, cw_Personne AS P |
1026 FROM cw_Note AS N, cw_Personne AS P |
1025 WHERE (N.cw_ecrit_par IS NULL OR N.cw_ecrit_par!=P.cw_eid) AND P.cw_nom=toto'''), |
1027 WHERE (N.cw_ecrit_par IS NULL OR N.cw_ecrit_par!=P.cw_eid) AND P.cw_nom=toto'''), |
1026 |
1028 |
1027 ('Any P WHERE N ecrit_par P, N eid 0', |
1029 ('Any P WHERE N ecrit_par P, N eid 0', |
1028 '''SELECT N.cw_ecrit_par |
1030 '''SELECT N.cw_ecrit_par |
1029 FROM cw_Note AS N |
1031 FROM cw_Note AS N |
1030 WHERE N.cw_ecrit_par IS NOT NULL AND N.cw_eid=0'''), |
1032 WHERE N.cw_ecrit_par IS NOT NULL AND N.cw_eid=0'''), |
1031 |
1033 |
1078 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0,cw_Division AS S WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) |
1080 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) |
1079 INTERSECT ALL |
1081 INTERSECT ALL |
1080 SELECT X.cw_nom |
1082 SELECT X.cw_nom |
1081 FROM cw_Personne AS X |
1083 FROM cw_Personne AS X |
1082 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0,cw_Societe AS S WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid)'''), |
1084 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)'''), |
1083 |
1085 |
1084 ('Any PN WHERE NOT X travaille S, S nom PN, S is IN(Division, Societe)', |
1086 ('Any PN WHERE NOT X travaille S, S nom PN, S is IN(Division, Societe)', |
1085 '''SELECT S.cw_nom |
1087 '''SELECT S.cw_nom |
1086 FROM cw_Division AS S |
1088 FROM cw_Division AS S |
1087 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=S.cw_eid) |
1089 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=S.cw_eid) |
1088 UNION ALL |
1090 UNION ALL |
1089 SELECT S.cw_nom |
1091 SELECT S.cw_nom |
1090 FROM cw_Societe AS S |
1092 FROM cw_Societe AS S |
1091 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=S.cw_eid)'''), |
1093 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=S.cw_eid)'''), |
1092 |
1094 |
1093 ('Personne X WHERE NOT X travaille S, S nom "chouette"', |
1095 ('Personne X WHERE NOT X travaille S, S nom "chouette"', |
1094 '''SELECT X.cw_eid |
1096 '''SELECT X.cw_eid |
1095 FROM cw_Division AS S, cw_Personne AS X |
1097 FROM cw_Division AS S, cw_Personne AS X |
1096 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) AND S.cw_nom=chouette |
1098 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 |
1097 UNION ALL |
1099 UNION ALL |
1100 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) AND S.cw_nom=chouette |
1102 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 |
1101 UNION ALL |
1103 UNION ALL |
1102 SELECT X.cw_eid |
1104 SELECT X.cw_eid |
1103 FROM cw_Personne AS X, cw_SubDivision AS S |
1105 FROM cw_Personne AS X, cw_SubDivision AS S |
1104 WHERE NOT EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=X.cw_eid AND rel_travaille0.eid_to=S.cw_eid) AND S.cw_nom=chouette'''), |
1106 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'''), |
1105 |
1107 |
1106 ('Any X WHERE X is ET, ET eid 2', |
1108 ('Any X WHERE X is ET, ET eid 2', |
1107 '''SELECT rel_is0.eid_from |
1109 '''SELECT rel_is0.eid_from |
1108 FROM is_relation AS rel_is0 |
1110 FROM is_relation AS rel_is0 |
1109 WHERE rel_is0.eid_to=2'''), |
1111 WHERE rel_is0.eid_to=2'''), |
1110 |
1112 |
1111 ] |
1113 ] |
1112 from logilab.common.adbh import ADV_FUNC_HELPER_DIRECTORY |
1114 from logilab.common.adbh import ADV_FUNC_HELPER_DIRECTORY |
1113 |
1115 |
1114 class PostgresSQLGeneratorTC(RQLGeneratorTC): |
1116 class PostgresSQLGeneratorTC(RQLGeneratorTC): |
1115 schema = schema |
1117 schema = schema |
1116 |
1118 |
1117 #capture = True |
1119 #capture = True |
1118 def setUp(self): |
1120 def setUp(self): |
1119 RQLGeneratorTC.setUp(self) |
1121 RQLGeneratorTC.setUp(self) |
1120 indexer = get_indexer('postgres', 'utf8') |
1122 indexer = get_indexer('postgres', 'utf8') |
1121 dbms_helper = ADV_FUNC_HELPER_DIRECTORY['postgres'] |
1123 dbms_helper = ADV_FUNC_HELPER_DIRECTORY['postgres'] |
1122 dbms_helper.fti_uid_attr = indexer.uid_attr |
1124 dbms_helper.fti_uid_attr = indexer.uid_attr |
1123 dbms_helper.fti_table = indexer.table |
1125 dbms_helper.fti_table = indexer.table |
1124 dbms_helper.fti_restriction_sql = indexer.restriction_sql |
1126 dbms_helper.fti_restriction_sql = indexer.restriction_sql |
1125 dbms_helper.fti_need_distinct_query = indexer.need_distinct |
1127 dbms_helper.fti_need_distinct_query = indexer.need_distinct |
1126 self.o = SQLGenerator(schema, dbms_helper) |
1128 self.o = SQLGenerator(schema, dbms_helper) |
1127 |
1129 |
1128 def _norm_sql(self, sql): |
1130 def _norm_sql(self, sql): |
1129 return sql.strip() |
1131 return sql.strip() |
1130 |
1132 |
1131 def _check(self, rql, sql, varmap=None): |
1133 def _check(self, rql, sql, varmap=None): |
1132 try: |
1134 try: |
1133 union = self._prepare(rql) |
1135 union = self._prepare(rql) |
1134 r, args = self.o.generate(union, {'text': 'hip hop momo'}, |
1136 r, args = self.o.generate(union, {'text': 'hip hop momo'}, |
1135 varmap=varmap) |
1137 varmap=varmap) |
1139 if 'r' in locals(): |
1141 if 'r' in locals(): |
1140 print (r%args).strip() |
1142 print (r%args).strip() |
1141 print '!=' |
1143 print '!=' |
1142 print sql.strip() |
1144 print sql.strip() |
1143 raise |
1145 raise |
1144 |
1146 |
1145 def _parse(self, rqls): |
1147 def _parse(self, rqls): |
1146 for rql, sql in rqls: |
1148 for rql, sql in rqls: |
1147 yield self._check, rql, sql |
1149 yield self._check, rql, sql |
1148 |
1150 |
1149 def _checkall(self, rql, sql): |
1151 def _checkall(self, rql, sql): |
1150 try: |
1152 try: |
1151 rqlst = self._prepare(rql) |
1153 rqlst = self._prepare(rql) |
1152 r, args = self.o.generate(rqlst) |
1154 r, args = self.o.generate(rqlst) |
1153 self.assertEqual((r.strip(), args), sql) |
1155 self.assertEqual((r.strip(), args), sql) |
1189 def test_cache_1(self): |
1191 def test_cache_1(self): |
1190 self._check('Any X WHERE X in_basket B, B eid 12', |
1192 self._check('Any X WHERE X in_basket B, B eid 12', |
1191 '''SELECT rel_in_basket0.eid_from |
1193 '''SELECT rel_in_basket0.eid_from |
1192 FROM in_basket_relation AS rel_in_basket0 |
1194 FROM in_basket_relation AS rel_in_basket0 |
1193 WHERE rel_in_basket0.eid_to=12''') |
1195 WHERE rel_in_basket0.eid_to=12''') |
1194 |
1196 |
1195 self._check('Any X WHERE X in_basket B, B eid 12', |
1197 self._check('Any X WHERE X in_basket B, B eid 12', |
1196 '''SELECT rel_in_basket0.eid_from |
1198 '''SELECT rel_in_basket0.eid_from |
1197 FROM in_basket_relation AS rel_in_basket0 |
1199 FROM in_basket_relation AS rel_in_basket0 |
1198 WHERE rel_in_basket0.eid_to=12''') |
1200 WHERE rel_in_basket0.eid_to=12''') |
1199 |
1201 |
1272 FROM cw_State AS X) |
1274 FROM cw_State AS X) |
1273 UNION ALL |
1275 UNION ALL |
1274 (SELECT XX.cw_name AS C0 |
1276 (SELECT XX.cw_name AS C0 |
1275 FROM cw_Transition AS XX)) AS _T0 |
1277 FROM cw_Transition AS XX)) AS _T0 |
1276 ORDER BY 1'''), |
1278 ORDER BY 1'''), |
1277 |
1279 |
1278 ('Any N,NX ORDERBY NX WITH N,NX BEING ' |
1280 ('Any N,NX ORDERBY NX WITH N,NX BEING ' |
1279 '((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
1281 '((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
1280 ' UNION ' |
1282 ' UNION ' |
1281 '(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
1283 '(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
1282 '''SELECT _T0.C0, _T0.C1 |
1284 '''SELECT _T0.C0, _T0.C1 |
1287 UNION ALL |
1289 UNION ALL |
1288 (SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
1290 (SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
1289 FROM cw_Transition AS X |
1291 FROM cw_Transition AS X |
1290 GROUP BY X.cw_name |
1292 GROUP BY X.cw_name |
1291 HAVING COUNT(X.cw_eid)>1)) AS _T0 |
1293 HAVING COUNT(X.cw_eid)>1)) AS _T0 |
1292 ORDER BY 2'''), |
1294 ORDER BY 2'''), |
1293 |
1295 |
1294 ('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
1296 ('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
1295 'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
1297 'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
1296 ' (Any X, N WHERE X name N, X is Transition))', |
1298 ' (Any X, N WHERE X name N, X is Transition))', |
1297 '''SELECT _T0.C1, COUNT(_T0.C0) |
1299 '''SELECT _T0.C1, COUNT(_T0.C0) |
1315 WHERE rel_is0.eid_from=_T0.C0 AND rel_is0.eid_to=ET.cw_eid |
1317 WHERE rel_is0.eid_from=_T0.C0 AND rel_is0.eid_to=ET.cw_eid |
1316 GROUP BY ET.cw_name'''), |
1318 GROUP BY ET.cw_name'''), |
1317 )): |
1319 )): |
1318 yield t |
1320 yield t |
1319 |
1321 |
1320 |
1322 |
1321 def test_subquery_error(self): |
1323 def test_subquery_error(self): |
1322 rql = ('Any N WHERE X name N WITH X BEING ' |
1324 rql = ('Any N WHERE X name N WITH X BEING ' |
1323 '((Any X WHERE X is State)' |
1325 '((Any X WHERE X is State)' |
1324 ' UNION ' |
1326 ' UNION ' |
1325 ' (Any X WHERE X is Transition))') |
1327 ' (Any X WHERE X is Transition))') |
1326 rqlst = self._prepare(rql) |
1328 rqlst = self._prepare(rql) |
1327 self.assertRaises(BadRQLQuery, self.o.generate, rqlst) |
1329 self.assertRaises(BadRQLQuery, self.o.generate, rqlst) |
1328 |
1330 |
1329 def test_symetric(self): |
1331 def test_symetric(self): |
1330 for t in self._parse(SYMETRIC): |
1332 for t in self._parse(SYMETRIC): |
1331 yield t |
1333 yield t |
1332 |
1334 |
1333 def test_inline(self): |
1335 def test_inline(self): |
1334 for t in self._parse(INLINE): |
1336 for t in self._parse(INLINE): |
1335 yield t |
1337 yield t |
1336 |
1338 |
1337 def test_has_text(self): |
1339 def test_has_text(self): |
1338 for t in self._parse(( |
1340 for t in self._parse(( |
1339 ('Any X WHERE X has_text "toto tata"', |
1341 ('Any X WHERE X has_text "toto tata"', |
1340 """SELECT appears0.uid |
1342 """SELECT appears0.uid |
1341 FROM appears AS appears0 |
1343 FROM appears AS appears0 |
1342 WHERE appears0.words @@ to_tsquery('default', 'toto&tata')"""), |
1344 WHERE appears0.words @@ to_tsquery('default', 'toto&tata')"""), |
1343 |
1345 |
1344 ('Personne X WHERE X has_text "toto tata"', |
1346 ('Personne X WHERE X has_text "toto tata"', |
1345 """SELECT X.eid |
1347 """SELECT X.eid |
1346 FROM appears AS appears0, entities AS X |
1348 FROM appears AS appears0, entities AS X |
1347 WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.eid AND X.type='Personne'"""), |
1349 WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.eid AND X.type='Personne'"""), |
1348 |
1350 |
1349 ('Personne X WHERE X has_text %(text)s', |
1351 ('Personne X WHERE X has_text %(text)s', |
1350 """SELECT X.eid |
1352 """SELECT X.eid |
1351 FROM appears AS appears0, entities AS X |
1353 FROM appears AS appears0, entities AS X |
1352 WHERE appears0.words @@ to_tsquery('default', 'hip&hop&momo') AND appears0.uid=X.eid AND X.type='Personne'"""), |
1354 WHERE appears0.words @@ to_tsquery('default', 'hip&hop&momo') AND appears0.uid=X.eid AND X.type='Personne'"""), |
1353 |
1355 |
1354 ('Any X WHERE X has_text "toto tata", X name "tutu"', |
1356 ('Any X WHERE X has_text "toto tata", X name "tutu"', |
1355 """SELECT X.cw_eid |
1357 """SELECT X.cw_eid |
1356 FROM appears AS appears0, cw_Basket AS X |
1358 FROM appears AS appears0, cw_Basket AS X |
1357 WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
1359 WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
1358 UNION ALL |
1360 UNION ALL |
1404 '''SELECT COUNT(1) |
1406 '''SELECT COUNT(1) |
1405 WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, cw_Affaire AS P WHERE rel_owned_by0.eid_from=P.cw_eid AND rel_owned_by0.eid_to=1 UNION SELECT 1 FROM owned_by_relation AS rel_owned_by1, cw_Note AS P WHERE rel_owned_by1.eid_from=P.cw_eid AND rel_owned_by1.eid_to=1)''') |
1407 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)''') |
1406 |
1408 |
1407 |
1409 |
1408 class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC): |
1410 class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC): |
1409 |
1411 |
1410 def setUp(self): |
1412 def setUp(self): |
1411 RQLGeneratorTC.setUp(self) |
1413 RQLGeneratorTC.setUp(self) |
1412 indexer = get_indexer('sqlite', 'utf8') |
1414 indexer = get_indexer('sqlite', 'utf8') |
1413 dbms_helper = ADV_FUNC_HELPER_DIRECTORY['sqlite'] |
1415 dbms_helper = ADV_FUNC_HELPER_DIRECTORY['sqlite'] |
1414 dbms_helper.fti_uid_attr = indexer.uid_attr |
1416 dbms_helper.fti_uid_attr = indexer.uid_attr |
1415 dbms_helper.fti_table = indexer.table |
1417 dbms_helper.fti_table = indexer.table |
1416 dbms_helper.fti_restriction_sql = indexer.restriction_sql |
1418 dbms_helper.fti_restriction_sql = indexer.restriction_sql |
1417 dbms_helper.fti_need_distinct_query = indexer.need_distinct |
1419 dbms_helper.fti_need_distinct_query = indexer.need_distinct |
1449 FROM cw_State AS X |
1451 FROM cw_State AS X |
1450 UNION ALL |
1452 UNION ALL |
1451 SELECT XX.cw_name AS C0 |
1453 SELECT XX.cw_name AS C0 |
1452 FROM cw_Transition AS XX) AS _T0 |
1454 FROM cw_Transition AS XX) AS _T0 |
1453 ORDER BY 1'''), |
1455 ORDER BY 1'''), |
1454 |
1456 |
1455 ('Any N,NX ORDERBY NX WITH N,NX BEING ' |
1457 ('Any N,NX ORDERBY NX WITH N,NX BEING ' |
1456 '((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
1458 '((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
1457 ' UNION ' |
1459 ' UNION ' |
1458 '(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
1460 '(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
1459 '''SELECT _T0.C0, _T0.C1 |
1461 '''SELECT _T0.C0, _T0.C1 |
1464 UNION ALL |
1466 UNION ALL |
1465 SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
1467 SELECT X.cw_name AS C0, COUNT(X.cw_eid) AS C1 |
1466 FROM cw_Transition AS X |
1468 FROM cw_Transition AS X |
1467 GROUP BY X.cw_name |
1469 GROUP BY X.cw_name |
1468 HAVING COUNT(X.cw_eid)>1) AS _T0 |
1470 HAVING COUNT(X.cw_eid)>1) AS _T0 |
1469 ORDER BY 2'''), |
1471 ORDER BY 2'''), |
1470 |
1472 |
1471 ('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
1473 ('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
1472 'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
1474 'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
1473 ' (Any X, N WHERE X name N, X is Transition))', |
1475 ' (Any X, N WHERE X name N, X is Transition))', |
1474 '''SELECT _T0.C1, COUNT(_T0.C0) |
1476 '''SELECT _T0.C1, COUNT(_T0.C0) |
1479 FROM cw_Transition AS X) AS _T0 |
1481 FROM cw_Transition AS X) AS _T0 |
1480 GROUP BY _T0.C1 |
1482 GROUP BY _T0.C1 |
1481 HAVING COUNT(_T0.C0)>1'''), |
1483 HAVING COUNT(_T0.C0)>1'''), |
1482 )): |
1484 )): |
1483 yield t |
1485 yield t |
1484 |
1486 |
1485 def test_has_text(self): |
1487 def test_has_text(self): |
1486 for t in self._parse(( |
1488 for t in self._parse(( |
1487 ('Any X WHERE X has_text "toto tata"', |
1489 ('Any X WHERE X has_text "toto tata"', |
1488 """SELECT appears0.uid |
1490 """SELECT appears0.uid |
1489 FROM appears AS appears0 |
1491 FROM appears AS appears0 |
1490 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
1492 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
1491 |
1493 |
1492 ('Any X WHERE X has_text %(text)s', |
1494 ('Any X WHERE X has_text %(text)s', |
1493 """SELECT appears0.uid |
1495 """SELECT appears0.uid |
1494 FROM appears AS appears0 |
1496 FROM appears AS appears0 |
1495 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('hip', 'hop', 'momo'))"""), |
1497 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('hip', 'hop', 'momo'))"""), |
1496 |
1498 |
1497 ('Personne X WHERE X has_text "toto tata"', |
1499 ('Personne X WHERE X has_text "toto tata"', |
1498 """SELECT X.eid |
1500 """SELECT X.eid |
1499 FROM appears AS appears0, entities AS X |
1501 FROM appears AS appears0, entities AS X |
1500 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.eid AND X.type='Personne'"""), |
1502 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.eid AND X.type='Personne'"""), |
1501 |
1503 |
1502 ('Any X WHERE X has_text "toto tata", X name "tutu"', |
1504 ('Any X WHERE X has_text "toto tata", X name "tutu"', |
1503 """SELECT X.cw_eid |
1505 """SELECT X.cw_eid |
1504 FROM appears AS appears0, cw_Basket AS X |
1506 FROM appears AS appears0, cw_Basket AS X |
1505 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=X.cw_eid AND X.cw_name=tutu |
1507 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 |
1506 UNION ALL |
1508 UNION ALL |
1534 |
1536 |
1535 class MySQLGenerator(PostgresSQLGeneratorTC): |
1537 class MySQLGenerator(PostgresSQLGeneratorTC): |
1536 |
1538 |
1537 def setUp(self): |
1539 def setUp(self): |
1538 RQLGeneratorTC.setUp(self) |
1540 RQLGeneratorTC.setUp(self) |
1539 indexer = get_indexer('mysql', 'utf8') |
1541 indexer = get_indexer('mysql', 'utf8') |
1540 dbms_helper = ADV_FUNC_HELPER_DIRECTORY['mysql'] |
1542 dbms_helper = ADV_FUNC_HELPER_DIRECTORY['mysql'] |
1541 dbms_helper.fti_uid_attr = indexer.uid_attr |
1543 dbms_helper.fti_uid_attr = indexer.uid_attr |
1542 dbms_helper.fti_table = indexer.table |
1544 dbms_helper.fti_table = indexer.table |
1543 dbms_helper.fti_restriction_sql = indexer.restriction_sql |
1545 dbms_helper.fti_restriction_sql = indexer.restriction_sql |
1544 dbms_helper.fti_need_distinct_query = indexer.need_distinct |
1546 dbms_helper.fti_need_distinct_query = indexer.need_distinct |
1545 self.o = SQLGenerator(schema, dbms_helper) |
1547 self.o = SQLGenerator(schema, dbms_helper) |
1546 |
1548 |
1547 def _norm_sql(self, sql): |
1549 def _norm_sql(self, sql): |
1548 return sql.strip().replace(' ILIKE ', ' LIKE ') |
1550 return sql.strip().replace(' ILIKE ', ' LIKE ').replace('TRUE', '1').replace('FALSE', '0') |
1549 |
1551 |
1550 def test_from_clause_needed(self): |
1552 def test_from_clause_needed(self): |
1551 queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')", |
1553 queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')", |
1552 '''SELECT 1 |
1554 '''SELECT 1 |
1553 FROM (SELECT 1) AS _T |
1555 FROM (SELECT 1) AS _T |
1604 FROM appears AS appears0, cw_Transition AS X |
1606 FROM appears AS appears0, cw_Transition AS X |
1605 WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu""") |
1607 WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=X.cw_eid AND X.cw_name=tutu""") |
1606 ] |
1608 ] |
1607 for t in self._parse(queries): |
1609 for t in self._parse(queries): |
1608 yield t |
1610 yield t |
1609 |
1611 |
1610 |
1612 |
1611 def test_ambigous_exists_no_from_clause(self): |
1613 def test_ambigous_exists_no_from_clause(self): |
1612 self._check('Any COUNT(U) WHERE U eid 1, EXISTS (P owned_by U, P is IN (Note, Affaire))', |
1614 self._check('Any COUNT(U) WHERE U eid 1, EXISTS (P owned_by U, P is IN (Note, Affaire))', |
1613 '''SELECT COUNT(1) |
1615 '''SELECT COUNT(1) |
1614 FROM (SELECT 1) AS _T |
1616 FROM (SELECT 1) AS _T |
1615 WHERE EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0, cw_Affaire AS P WHERE rel_owned_by0.eid_from=P.cw_eid AND rel_owned_by0.eid_to=1 UNION SELECT 1 FROM owned_by_relation AS rel_owned_by1, cw_Note AS P WHERE rel_owned_by1.eid_from=P.cw_eid AND rel_owned_by1.eid_to=1)''') |
1617 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)''') |
1616 |
1618 |
1617 |
1619 |
1618 |
1620 |
1619 |
1621 |
1620 if __name__ == '__main__': |
1622 if __name__ == '__main__': |
1621 unittest_main() |
1623 unittest_main() |