author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 07 Jul 2011 18:33:21 +0200 | |
changeset 7637 | a8a3fcdb1f6e |
parent 7599 | 9cbf4c86f57a |
child 7642 | 64eee2a83bfa |
permissions | -rw-r--r-- |
7043
686010f3a83e
some copyrigh updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6940
diff
changeset
|
1 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""unit tests for module cubicweb.server.sources.rql2sql""" |
19 |
||
20 |
import sys |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
21 |
import os |
0 | 22 |
|
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
|
23 |
from logilab.common.testlib import TestCase, unittest_main, mock_object |
0 | 24 |
|
25 |
from rql import BadRQLQuery |
|
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
26 |
from rql.utils import register_function, FunctionDescr |
0 | 27 |
|
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
28 |
from cubicweb.devtools import TestServerConfiguration |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
29 |
from cubicweb.devtools.repotest import RQLGeneratorTC |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
30 |
from cubicweb.server.sources.rql2sql import remove_unused_solutions |
0 | 31 |
|
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
32 |
|
0 | 33 |
# add a dumb registered procedure |
34 |
class stockproc(FunctionDescr): |
|
35 |
supported_backends = ('postgres', 'sqlite', 'mysql') |
|
36 |
try: |
|
37 |
register_function(stockproc) |
|
38 |
except AssertionError, ex: |
|
39 |
pass # already registered |
|
40 |
||
7142
c47381851a3e
[sql generation test] avoid lgdb warnings when a db module is faked
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7108
diff
changeset
|
41 |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
42 |
from logilab import database as db |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
43 |
def monkey_patch_import_driver_module(driver, drivers, quiet=True): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
44 |
if not driver in drivers: |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
45 |
raise db.UnknownDriver(driver) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
46 |
for modname in drivers[driver]: |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
47 |
try: |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
48 |
if not quiet: |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
49 |
print >> sys.stderr, 'Trying %s' % modname |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
50 |
module = db.load_module_from_name(modname, use_sys=False) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
51 |
break |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
52 |
except ImportError: |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
53 |
if not quiet: |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
54 |
print >> sys.stderr, '%s is not available' % modname |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
55 |
continue |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
56 |
else: |
7142
c47381851a3e
[sql generation test] avoid lgdb warnings when a db module is faked
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7108
diff
changeset
|
57 |
return mock_object(STRING=1, BOOLEAN=2, BINARY=3, DATETIME=4, NUMBER=5), drivers[driver][0] |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
58 |
return module, modname |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
59 |
|
0 | 60 |
|
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6631
diff
changeset
|
61 |
def setUpModule(): |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
62 |
global config, schema |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
63 |
config = TestServerConfiguration('data', apphome=CWRQLTC.datadir) |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
64 |
config.bootstrap_cubes() |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
65 |
schema = config.load_schema() |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
66 |
schema['in_state'].inlined = True |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
67 |
schema['state_of'].inlined = False |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
68 |
schema['comments'].inlined = False |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
69 |
db._backup_import_driver_module = db._import_driver_module |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
70 |
db._import_driver_module = monkey_patch_import_driver_module |
0 | 71 |
|
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6631
diff
changeset
|
72 |
def tearDownModule(): |
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
|
73 |
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
|
74 |
del config, schema |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
75 |
db._import_driver_module = db._backup_import_driver_module |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
76 |
del db._backup_import_driver_module |
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
|
77 |
|
0 | 78 |
PARSER = [ |
79 |
(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
|
80 |
'''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
|
81 |
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
|
82 |
WHERE _P.cw_nom=Zig\'oto'''), |
0 | 83 |
|
84 |
(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
|
85 |
'''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
|
86 |
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
|
87 |
WHERE _P.cw_nom ILIKE Zig"oto%'''), |
0 | 88 |
] |
89 |
||
90 |
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
|
91 |
|
3762
e416186fb91c
prefix sql aliases for entity table by '_' to avoid pb with variable such as 'AS' (eg a keyword in SQL)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3752
diff
changeset
|
92 |
("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
|
93 |
'''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
|
94 |
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
|
95 |
|
0 | 96 |
("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
|
97 |
'''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
|
98 |
FROM cw_Affaire AS _X'''), |
1787 | 99 |
|
0 | 100 |
("Any X WHERE X eid 0", |
101 |
'''SELECT 0'''), |
|
1787 | 102 |
|
0 | 103 |
("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
|
104 |
'''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
|
105 |
FROM cw_Personne AS _P'''), |
0 | 106 |
|
107 |
("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
|
108 |
'''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
|
109 |
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
|
110 |
WHERE _P.cw_test=TRUE'''), |
0 | 111 |
|
112 |
("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
|
113 |
'''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
|
114 |
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
|
115 |
WHERE _P.cw_test=FALSE'''), |
0 | 116 |
|
117 |
("Personne P WHERE P eid -1", |
|
118 |
'''SELECT -1'''), |
|
119 |
||
120 |
("Personne P WHERE S is Societe, P travaille S, S nom 'Logilab';", |
|
121 |
'''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
|
122 |
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
|
123 |
WHERE rel_travaille0.eid_to=_S.cw_eid AND _S.cw_nom=Logilab'''), |
0 | 124 |
|
125 |
("Personne P WHERE P concerne A, A concerne S, S nom 'Logilab', S is Societe;", |
|
126 |
'''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
|
127 |
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
|
128 |
WHERE rel_concerne0.eid_to=rel_concerne1.eid_from AND rel_concerne1.eid_to=_S.cw_eid AND _S.cw_nom=Logilab'''), |
0 | 129 |
|
130 |
("Note N WHERE X evaluee N, X nom 'Logilab';", |
|
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_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
|
133 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom=Logilab |
0 | 134 |
UNION ALL |
135 |
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
|
136 |
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
|
137 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom=Logilab |
0 | 138 |
UNION ALL |
139 |
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
|
140 |
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
|
141 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom=Logilab |
0 | 142 |
UNION ALL |
143 |
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
|
144 |
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
|
145 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom=Logilab'''), |
0 | 146 |
|
147 |
("Note N WHERE X evaluee N, X nom in ('Logilab', 'Caesium');", |
|
148 |
'''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
|
149 |
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
|
150 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom IN(Logilab, Caesium) |
0 | 151 |
UNION ALL |
152 |
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
|
153 |
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
|
154 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom IN(Logilab, Caesium) |
0 | 155 |
UNION ALL |
156 |
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
|
157 |
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
|
158 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom IN(Logilab, Caesium) |
0 | 159 |
UNION ALL |
160 |
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
|
161 |
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
|
162 |
WHERE rel_evaluee0.eid_from=_X.cw_eid AND _X.cw_nom IN(Logilab, Caesium)'''), |
0 | 163 |
|
164 |
("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
|
165 |
'''SELECT _X.cw_eid |
e416186fb91c
prefix sql aliases for entity table by '_' to avoid pb with variable such as 'AS' (eg a keyword in SQL)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3752
diff
changeset
|
166 |
FROM cw_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
|
167 |
WHERE DATE(_X.cw_creation_date)=CURRENT_DATE'''), |
0 | 168 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
169 |
("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
|
170 |
'''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
|
171 |
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
|
172 |
WHERE rel_read_permission0.eid_from=12 AND rel_read_permission0.eid_to=_G.cw_eid'''), |
0 | 173 |
|
174 |
('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
|
175 |
"""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
|
176 |
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
|
177 |
WHERE _U.cw_login=admin"""), |
0 | 178 |
|
179 |
('Any T WHERE T tags X, X is State', |
|
180 |
'''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
|
181 |
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
|
182 |
WHERE rel_tags0.eid_to=_X.cw_eid'''), |
0 | 183 |
|
184 |
('Any X,Y WHERE X eid 0, Y eid 1, X concerne Y', |
|
185 |
'''SELECT 0, 1 |
|
186 |
FROM concerne_relation AS rel_concerne0 |
|
187 |
WHERE rel_concerne0.eid_from=0 AND rel_concerne0.eid_to=1'''), |
|
188 |
||
189 |
("Any X WHERE X prenom 'lulu'," |
|
190 |
"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
|
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_Personne AS _X |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
193 |
WHERE _X.cw_prenom=lulu AND EXISTS(SELECT 1 FROM cw_CWGroup AS _G, in_group_relation AS rel_in_group1, owned_by_relation AS rel_owned_by0 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 | 194 |
|
195 |
("Any X WHERE X prenom 'lulu'," |
|
196 |
"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
|
197 |
'''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
|
198 |
FROM cw_Personne AS _X |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
199 |
WHERE _X.cw_prenom=lulu AND NOT (EXISTS(SELECT 1 FROM cw_CWGroup AS _G, in_group_relation AS rel_in_group1, owned_by_relation AS rel_owned_by0 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
|
200 |
|
6940
1172c25655b7
[rql2sql] should not select a neged relation as principal + simplify code for sql generation for attribute relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6930
diff
changeset
|
201 |
('Any X WHERE X title V, NOT X wikiid V, NOT X title "parent", X is Card', |
1172c25655b7
[rql2sql] should not select a neged relation as principal + simplify code for sql generation for attribute relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6930
diff
changeset
|
202 |
'''SELECT _X.cw_eid |
1172c25655b7
[rql2sql] should not select a neged relation as principal + simplify code for sql generation for attribute relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6930
diff
changeset
|
203 |
FROM cw_Card AS _X |
1172c25655b7
[rql2sql] should not select a neged relation as principal + simplify code for sql generation for attribute relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6930
diff
changeset
|
204 |
WHERE NOT (_X.cw_wikiid=_X.cw_title) AND NOT (_X.cw_title=parent)''') |
5886 | 205 |
] |
3815
50b87f759b5d
test and fix http://www.logilab.org/ticket/499838
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3762
diff
changeset
|
206 |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
207 |
BASIC_WITH_LIMIT = [ |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
208 |
("Personne P LIMIT 20 OFFSET 10", |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
209 |
'''SELECT _P.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
210 |
FROM cw_Personne AS _P |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
211 |
LIMIT 20 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
212 |
OFFSET 10'''), |
7596
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
213 |
("Any P ORDERBY N LIMIT 1 WHERE P is Personne, P travaille S, S eid %(eid)s, P nom N, P nom %(text)s", |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
214 |
'''SELECT _P.cw_eid |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
215 |
FROM cw_Personne AS _P, travaille_relation AS rel_travaille0 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
216 |
WHERE rel_travaille0.eid_from=_P.cw_eid AND rel_travaille0.eid_to=12345 AND _P.cw_nom=hip hop momo |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
217 |
ORDER BY _P.cw_nom |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
218 |
LIMIT 1'''), |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
219 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
220 |
|
0 | 221 |
|
6929
e9464d975908
[rql2sql] fix bug with NOT in "fake" having terms
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
222 |
ADVANCED = [ |
0 | 223 |
("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
|
224 |
'''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
|
225 |
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
|
226 |
WHERE ((_S.cw_nom=Logilab) OR (_S.cw_nom=Caesium))'''), |
1787 | 227 |
|
0 | 228 |
('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
|
229 |
'''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
|
230 |
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
|
231 |
WHERE _X.cw_nom=toto AND _X.cw_eid IN(9700, 9710, 1045, 674) |
0 | 232 |
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
|
233 |
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
|
234 |
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
|
235 |
WHERE _X.cw_nom=toto AND _X.cw_eid IN(9700, 9710, 1045, 674) |
0 | 236 |
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
|
237 |
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
|
238 |
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
|
239 |
WHERE _X.cw_nom=toto AND _X.cw_eid IN(9700, 9710, 1045, 674) |
0 | 240 |
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
|
241 |
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
|
242 |
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
|
243 |
WHERE _X.cw_nom=toto AND _X.cw_eid IN(9700, 9710, 1045, 674)'''), |
0 | 244 |
|
245 |
('Any Y, COUNT(N) GROUPBY Y WHERE Y evaluee N;', |
|
246 |
'''SELECT rel_evaluee0.eid_from, COUNT(rel_evaluee0.eid_to) |
|
247 |
FROM evaluee_relation AS rel_evaluee0 |
|
248 |
GROUP BY rel_evaluee0.eid_from'''), |
|
249 |
||
250 |
("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
|
251 |
'''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
|
252 |
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
|
253 |
WHERE ((rel_concerne0.eid_from=_X.cw_eid) OR (rel_concerne1.eid_to=_X.cw_eid))'''), |
0 | 254 |
|
255 |
("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
|
256 |
'''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
|
257 |
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
|
258 |
WHERE ((rel_travaille0.eid_from=_X.cw_eid) OR (rel_concerne1.eid_from=_X.cw_eid))'''), |
0 | 259 |
|
260 |
("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
|
261 |
'''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
|
262 |
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
|
263 |
WHERE ((rel_evaluee0.eid_to=_N.cw_eid) OR (_N.cw_ecrit_par IS NOT NULL))'''), |
0 | 264 |
|
265 |
("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
|
266 |
'''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
|
267 |
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
|
268 |
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 | 269 |
|
270 |
("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
|
271 |
'''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
|
272 |
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
|
273 |
WHERE ((rel_evaluee0.eid_to=_N.cw_eid) OR (rel_todo_by1.eid_from=_N.cw_eid))'''), |
1787 | 274 |
|
0 | 275 |
("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
|
276 |
'''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
|
277 |
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
|
278 |
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 | 279 |
|
280 |
('Any X WHERE X created_by U, X concerne B OR C concerne X, B eid 12, C eid 13', |
|
281 |
'''SELECT rel_created_by0.eid_from |
|
282 |
FROM concerne_relation AS rel_concerne1, concerne_relation AS rel_concerne2, created_by_relation AS rel_created_by0 |
|
283 |
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))'''), |
|
284 |
||
285 |
('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
|
286 |
'''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
|
287 |
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
|
288 |
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 | 289 |
|
290 |
('Any X WHERE T tags X', |
|
291 |
'''SELECT rel_tags0.eid_to |
|
292 |
FROM tags_relation AS rel_tags0'''), |
|
1787 | 293 |
|
0 | 294 |
('Any X WHERE X in_basket B, B eid 12', |
295 |
'''SELECT rel_in_basket0.eid_from |
|
296 |
FROM in_basket_relation AS rel_in_basket0 |
|
297 |
WHERE rel_in_basket0.eid_to=12'''), |
|
1787 | 298 |
|
0 | 299 |
('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
|
300 |
'''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
|
301 |
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
|
302 |
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 | 303 |
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
|
304 |
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
|
305 |
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
|
306 |
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 | 307 |
|
308 |
# 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 |
|
309 |
('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
|
310 |
'''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
|
311 |
FROM cw_Note AS _S, cw_Personne AS _O |
6003
5fbc1c4c13ff
[rql2sql] fix bug with NOT of inlined relation: NULL values are not properly handled and hence some rows won't be returned while the should
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5901
diff
changeset
|
312 |
WHERE (_S.cw_ecrit_par IS NULL OR _S.cw_ecrit_par!=_O.cw_eid) AND _S.cw_eid=1 AND _S.cw_inline1 IS NOT NULL AND _O.cw_inline2=_S.cw_inline1'''), |
0 | 313 |
|
314 |
('Any N WHERE N todo_by U, N is Note, U eid 2, N filed_under T, T eid 3', |
|
315 |
# 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
|
316 |
'''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
|
317 |
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
|
318 |
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 | 319 |
|
320 |
('Any N WHERE N todo_by U, U eid 2, P evaluee N, P eid 3', |
|
321 |
'''SELECT rel_evaluee1.eid_to |
|
322 |
FROM evaluee_relation AS rel_evaluee1, todo_by_relation AS rel_todo_by0 |
|
323 |
WHERE rel_evaluee1.eid_to=rel_todo_by0.eid_from AND rel_todo_by0.eid_to=2 AND rel_evaluee1.eid_from=3'''), |
|
324 |
||
1787 | 325 |
|
0 | 326 |
(' Any X,U WHERE C owned_by U, NOT X owned_by U, C eid 1, X eid 2', |
327 |
'''SELECT 2, rel_owned_by0.eid_to |
|
328 |
FROM owned_by_relation AS rel_owned_by0 |
|
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
329 |
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))'''), |
0 | 330 |
|
331 |
('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
|
332 |
'''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
|
333 |
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
|
334 |
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 | 335 |
|
336 |
('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
|
337 |
"""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
|
338 |
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
|
339 |
WHERE EXISTS(SELECT 1 FROM documented_by_relation AS rel_documented_by0 WHERE rel_documented_by0.eid_to=_C.cw_eid)"""), |
1787 | 340 |
|
0 | 341 |
('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
|
342 |
"""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
|
343 |
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
|
344 |
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 | 345 |
|
346 |
('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
|
347 |
"""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
|
348 |
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
|
349 |
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 | 350 |
|
351 |
('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
|
352 |
'''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
|
353 |
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
|
354 |
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 | 355 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
356 |
('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
|
357 |
'''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
|
358 |
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
|
359 |
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
|
360 |
GROUP BY _X.cw_eid'''), |
0 | 361 |
|
362 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
363 |
('Any X WHERE Y evaluee X, Y is CWUser', |
0 | 364 |
'''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
|
365 |
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
|
366 |
WHERE rel_evaluee0.eid_from=_Y.cw_eid'''), |
0 | 367 |
|
368 |
('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
|
369 |
'''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
|
370 |
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
|
371 |
WHERE _X.cw_login=admin AND _X.cw_eid=_Y.cw_eid'''), |
0 | 372 |
|
373 |
('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
|
374 |
'''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
|
375 |
FROM cw_CWUser AS _X, cw_CWUser AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
376 |
WHERE _X.cw_login=admin AND NOT (_X.cw_eid=_Y.cw_eid)'''), |
1787 | 377 |
|
0 | 378 |
('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
|
379 |
'''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
|
380 |
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
|
381 |
WHERE _X.cw_login=admin'''), |
0 | 382 |
|
3587 | 383 |
('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
|
384 |
'''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
|
385 |
FROM cw_Basket AS _X |
0 | 386 |
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
|
387 |
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
|
388 |
FROM cw_Folder AS _X |
0 | 389 |
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
|
390 |
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
|
391 |
FROM cw_Tag AS _X |
0 | 392 |
ORDER BY 1'''), |
393 |
||
2916
f42029293e59
cleanup, use striplines argument of assertLinesEquals
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2915
diff
changeset
|
394 |
# 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
|
395 |
('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
|
396 |
'''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
|
397 |
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
|
398 |
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 | 399 |
|
400 |
# 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
|
401 |
('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
|
402 |
'''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
|
403 |
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
|
404 |
WHERE _X.cw_name=CWGroup AND _Y.cw_eid IN(1, 2, 3) AND EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=_X.cw_eid AND rel_read_permission0.eid_to=_Y.cw_eid) |
0 | 405 |
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
|
406 |
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
|
407 |
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
|
408 |
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 | 409 |
|
410 |
# 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
|
411 |
('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
|
412 |
'''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
|
413 |
FROM cw_CWEType AS _X, cw_CWGroup AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
414 |
WHERE _X.cw_name=CWGroup AND _Y.cw_eid IN(1, 2, 3) AND NOT (EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=_X.cw_eid AND rel_read_permission0.eid_to=_Y.cw_eid)) |
0 | 415 |
UNION |
3762
e416186fb91c
prefix sql aliases for entity table by '_' to avoid pb with variable such as 'AS' (eg a keyword in SQL)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3752
diff
changeset
|
416 |
SELECT 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
|
417 |
FROM cw_CWEType AS _X, cw_RQLExpression AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
418 |
WHERE _X.cw_name=CWGroup AND _Y.cw_eid IN(1, 2, 3) AND NOT (EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=_X.cw_eid AND rel_read_permission0.eid_to=_Y.cw_eid))'''), |
0 | 419 |
|
420 |
# 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
|
421 |
('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
|
422 |
'''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
|
423 |
FROM cw_CWEType AS _X, cw_CWGroup AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
424 |
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 | 425 |
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
|
426 |
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
|
427 |
FROM cw_CWEType AS _X, cw_RQLExpression AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
428 |
WHERE _X.cw_name=CWGroup AND _Y.cw_eid IN(1, 2, 3) AND NOT (EXISTS(SELECT 1 FROM read_permission_relation AS rel_read_permission0 WHERE rel_read_permission0.eid_from=_X.cw_eid AND rel_read_permission0.eid_to=_Y.cw_eid))'''), |
1787 | 429 |
|
0 | 430 |
# 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
|
431 |
('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
|
432 |
'''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
|
433 |
FROM cw_CWEType AS _X, cw_CWGroup AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
434 |
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 | 435 |
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
|
436 |
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
|
437 |
FROM cw_CWEType AS _X, cw_RQLExpression AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
438 |
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 | 439 |
|
3587 | 440 |
('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
|
441 |
'''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
|
442 |
FROM cw_Basket AS _X |
0 | 443 |
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
|
444 |
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
|
445 |
FROM cw_Folder AS _X |
0 | 446 |
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
|
447 |
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
|
448 |
FROM cw_Tag AS _X) AS T1 |
0 | 449 |
GROUP BY T1.C1'''), |
1787 | 450 |
|
3587 | 451 |
('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;', |
5575
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
452 |
'''SELECT (MAX(_X.cw_eid) + MIN(LENGTH(_X.cw_data))), _X.cw_data_name |
3762
e416186fb91c
prefix sql aliases for entity table by '_' to avoid pb with variable such as 'AS' (eg a keyword in SQL)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3752
diff
changeset
|
453 |
FROM cw_File AS _X |
5575
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
454 |
GROUP BY _X.cw_data_name,_X.cw_data_format |
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
455 |
ORDER BY 1,2,_X.cw_data_format'''), |
0 | 456 |
|
457 |
# 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
|
458 |
('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
|
459 |
'''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
|
460 |
FROM cw_Tag AS _T |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
461 |
WHERE NOT (_T.cw_name IN(t1, t2)) AND EXISTS(SELECT 1 FROM cw_CWGroup AS _X, tags_relation AS rel_tags0 WHERE rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_X.cw_eid UNION SELECT 1 FROM cw_CWUser AS _X, tags_relation AS rel_tags1 WHERE rel_tags1.eid_from=_T.cw_eid AND rel_tags1.eid_to=_X.cw_eid)'''), |
0 | 462 |
|
1787 | 463 |
# must not use a relation in EXISTS scope to inline a variable |
0 | 464 |
('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
|
465 |
'''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
|
466 |
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
|
467 |
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 | 468 |
|
469 |
('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
|
470 |
'''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
|
471 |
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
|
472 |
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 | 473 |
|
474 |
('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
|
475 |
'''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
|
476 |
FROM cw_CWUser AS _U |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
477 |
WHERE EXISTS(SELECT 1 FROM cw_Affaire AS _P, owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_from=_P.cw_eid AND rel_owned_by0.eid_to=_U.cw_eid UNION SELECT 1 FROM cw_Note AS _P, owned_by_relation AS rel_owned_by1 WHERE rel_owned_by1.eid_from=_P.cw_eid AND rel_owned_by1.eid_to=_U.cw_eid)'''), |
0 | 478 |
|
479 |
('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
|
480 |
'''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
|
481 |
FROM entities AS _X'''), |
0 | 482 |
|
483 |
('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
|
484 |
'''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
|
485 |
FROM cw_Note AS _X'''), |
1787 | 486 |
|
0 | 487 |
('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
|
488 |
'''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
|
489 |
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
|
490 |
WHERE _X.eid>12'''), |
1787 | 491 |
|
0 | 492 |
('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
|
493 |
"""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
|
494 |
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
|
495 |
WHERE _X.type='Note' AND _X.eid>12"""), |
1787 | 496 |
|
3520
eb508952ee81
update test, record a failing test (commented out)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3245
diff
changeset
|
497 |
('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
|
498 |
"""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
|
499 |
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
|
500 |
WHERE _X.cw_eid>12 |
0 | 501 |
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
|
502 |
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
|
503 |
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
|
504 |
WHERE _X.cw_eid>12"""), |
0 | 505 |
|
506 |
('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
|
507 |
'''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
|
508 |
FROM entities AS _X'''), |
0 | 509 |
|
510 |
('Any X GROUPBY X WHERE X eid 12', |
|
511 |
'''SELECT 12'''), |
|
1787 | 512 |
|
0 | 513 |
('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
|
514 |
'''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
|
515 |
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
|
516 |
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
|
517 |
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
|
518 |
ORDER BY _X.cw_login'''), |
1787 | 519 |
|
0 | 520 |
('Any U,COUNT(X) GROUPBY U WHERE U eid 12, X owned_by U HAVING COUNT(X) > 10', |
521 |
'''SELECT rel_owned_by0.eid_to, COUNT(rel_owned_by0.eid_from) |
|
522 |
FROM owned_by_relation AS rel_owned_by0 |
|
523 |
WHERE rel_owned_by0.eid_to=12 |
|
524 |
GROUP BY rel_owned_by0.eid_to |
|
525 |
HAVING COUNT(rel_owned_by0.eid_from)>10'''), |
|
526 |
||
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
527 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
528 |
("Any X WHERE X eid 0, X test TRUE", |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
529 |
'''SELECT _X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
530 |
FROM cw_Personne AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
531 |
WHERE _X.cw_eid=0 AND _X.cw_test=TRUE'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
532 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
533 |
('Any 1 WHERE X in_group G, X is CWUser', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
534 |
'''SELECT 1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
535 |
FROM in_group_relation AS rel_in_group0'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
536 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
537 |
('CWEType X WHERE X name CV, X description V HAVING NOT V=CV AND NOT V = "parent"', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
538 |
'''SELECT _X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
539 |
FROM cw_CWEType AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
540 |
WHERE NOT (EXISTS(SELECT 1 WHERE _X.cw_description=parent)) AND NOT (EXISTS(SELECT 1 WHERE _X.cw_description=_X.cw_name))'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
541 |
('CWEType X WHERE X name CV, X description V HAVING V!=CV AND V != "parent"', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
542 |
'''SELECT _X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
543 |
FROM cw_CWEType AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
544 |
WHERE _X.cw_description!=parent AND _X.cw_description!=_X.cw_name'''), |
7421
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
545 |
|
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
546 |
('DISTINCT Any X, SUM(C) GROUPBY X ORDERBY SUM(C) DESC WHERE H todo_by X, H duration C', |
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
547 |
'''SELECT DISTINCT rel_todo_by0.eid_to, SUM(_H.cw_duration) |
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
548 |
FROM cw_Affaire AS _H, todo_by_relation AS rel_todo_by0 |
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
549 |
WHERE rel_todo_by0.eid_from=_H.cw_eid |
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
550 |
GROUP BY rel_todo_by0.eid_to |
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
551 |
ORDER BY 2 DESC'''), |
5115daeeb2ff
[rql2sql] closes #1697862: ORDERBY SUM(C) cancel GROUPBY by wrongly adding C to grouped variables
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7396
diff
changeset
|
552 |
|
7497
7beb71d76d82
[rql2sql] add test case for 7493:3c46b9390871
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7473
diff
changeset
|
553 |
('Any R2 WHERE R2 concerne R, R eid RE, R2 eid > RE', |
7beb71d76d82
[rql2sql] add test case for 7493:3c46b9390871
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7473
diff
changeset
|
554 |
'''SELECT _R2.eid |
7beb71d76d82
[rql2sql] add test case for 7493:3c46b9390871
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7473
diff
changeset
|
555 |
FROM concerne_relation AS rel_concerne0, entities AS _R2 |
7beb71d76d82
[rql2sql] add test case for 7493:3c46b9390871
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7473
diff
changeset
|
556 |
WHERE _R2.eid=rel_concerne0.eid_from AND _R2.eid>rel_concerne0.eid_to'''), |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
557 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
558 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
559 |
ADVANCED_WITH_GROUP_CONCAT = [ |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
560 |
("Any X,GROUP_CONCAT(TN) GROUPBY X ORDERBY XN WHERE T tags X, X name XN, T name TN, X is CWGroup", |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
561 |
'''SELECT _X.cw_eid, GROUP_CONCAT(_T.cw_name) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
562 |
FROM cw_CWGroup AS _X, cw_Tag AS _T, tags_relation AS rel_tags0 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
563 |
WHERE rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
564 |
GROUP BY _X.cw_eid,_X.cw_name |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
565 |
ORDER BY _X.cw_name'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
566 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
567 |
("Any X,GROUP_CONCAT(TN) GROUPBY X ORDERBY XN WHERE T tags X, X name XN, T name TN", |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
568 |
'''SELECT T1.C0, GROUP_CONCAT(T1.C1) FROM (SELECT _X.cw_eid AS C0, _T.cw_name AS C1, _X.cw_name AS C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
569 |
FROM cw_CWGroup AS _X, cw_Tag AS _T, tags_relation AS rel_tags0 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
570 |
WHERE rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
571 |
UNION ALL |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
572 |
SELECT _X.cw_eid AS C0, _T.cw_name AS C1, _X.cw_name AS C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
573 |
FROM cw_State AS _X, cw_Tag AS _T, tags_relation AS rel_tags0 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
574 |
WHERE rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
575 |
UNION ALL |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
576 |
SELECT _X.cw_eid AS C0, _T.cw_name AS C1, _X.cw_name AS C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
577 |
FROM cw_Tag AS _T, cw_Tag AS _X, tags_relation AS rel_tags0 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
578 |
WHERE rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_X.cw_eid) AS T1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
579 |
GROUP BY T1.C0,T1.C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
580 |
ORDER BY T1.C2'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
581 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
582 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
583 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
584 |
ADVANCED_WITH_LIMIT_OR_ORDERBY = [ |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
585 |
('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"))', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
586 |
'''SELECT COUNT(rel_concerne0.eid_from), _C.cw_nom |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
587 |
FROM concerne_relation AS rel_concerne0, cw_Societe AS _C |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
588 |
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 cw_Card AS _N, documented_by_relation AS rel_documented_by2 WHERE rel_concerne0.eid_from=rel_documented_by2.eid_from AND rel_documented_by2.eid_to=_N.cw_eid AND _N.cw_title=published))) |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
589 |
GROUP BY _C.cw_nom |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
590 |
ORDER BY 1 DESC |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
591 |
LIMIT 10'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
592 |
('DISTINCT Any S ORDERBY stockproc(SI) WHERE NOT S ecrit_par O, S para SI', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
593 |
'''SELECT T1.C0 FROM (SELECT DISTINCT _S.cw_eid AS C0, STOCKPROC(_S.cw_para) AS C1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
594 |
FROM cw_Note AS _S |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
595 |
WHERE _S.cw_ecrit_par IS NULL |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
596 |
ORDER BY 2) AS T1'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
597 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
598 |
('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;', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
599 |
'''SELECT T1.C0,T1.C1 FROM (SELECT DISTINCT (MAX(_X.cw_eid) + MIN(LENGTH(_X.cw_data))) AS C0, _X.cw_data_name AS C1, _X.cw_data_format AS C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
600 |
FROM cw_File AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
601 |
GROUP BY _X.cw_data_name,_X.cw_data_format |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
602 |
ORDER BY 2,3) AS T1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
603 |
'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
604 |
|
0 | 605 |
('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
|
606 |
'''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
|
607 |
FROM cw_CWUser AS _U |
0 | 608 |
ORDER BY 2) AS T1'''), |
1787 | 609 |
|
0 | 610 |
('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
|
611 |
'''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
|
612 |
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
|
613 |
WHERE rel_bookmarked_by0.eid_to=_X.cw_eid |
0 | 614 |
ORDER BY 2) AS T1'''), |
615 |
||
616 |
('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
|
617 |
'''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
|
618 |
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
|
619 |
WHERE _X.cw_in_state=_S.cw_eid |
0 | 620 |
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
|
621 |
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
|
622 |
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
|
623 |
WHERE _X.cw_in_state=_S.cw_eid |
0 | 624 |
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
|
625 |
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
|
626 |
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
|
627 |
WHERE _X.cw_in_state=_S.cw_eid |
0 | 628 |
ORDER BY 2) AS T1'''), |
629 |
||
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
|
630 |
('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
|
631 |
'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
|
632 |
'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
|
633 |
'''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
|
634 |
FROM cw_EmailAddress AS _O |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
635 |
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
|
636 |
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
|
637 |
|
874f5a73e89f
[rql2sql] test we don't crash on dumb queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
638 |
|
0 | 639 |
] |
640 |
||
641 |
MULTIPLE_SEL = [ |
|
642 |
("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
|
643 |
'''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
|
644 |
FROM cw_Personne AS _P'''), |
0 | 645 |
("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
|
646 |
'''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
|
647 |
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
|
648 |
WHERE NOT (_P.cw_nom IS NULL)'''), |
0 | 649 |
("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
|
650 |
'''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
|
651 |
FROM cw_Personne AS _X, cw_Personne AS _Y |
7396
8345ee2c2ea6
[rql2sql] fix in 7394:d11d88bd08e8 was actually not needed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7357
diff
changeset
|
652 |
WHERE _Y.cw_nom=_X.cw_nom AND NOT (_Y.cw_eid=_X.cw_eid)'''), |
8345ee2c2ea6
[rql2sql] fix in 7394:d11d88bd08e8 was actually not needed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7357
diff
changeset
|
653 |
|
8345ee2c2ea6
[rql2sql] fix in 7394:d11d88bd08e8 was actually not needed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7357
diff
changeset
|
654 |
('Any X,Y WHERE X is Personne, Y is Personne, X nom XD, Y nom XD, X eid Z, Y eid > Z', |
8345ee2c2ea6
[rql2sql] fix in 7394:d11d88bd08e8 was actually not needed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7357
diff
changeset
|
655 |
'''SELECT _X.cw_eid, _Y.cw_eid |
8345ee2c2ea6
[rql2sql] fix in 7394:d11d88bd08e8 was actually not needed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7357
diff
changeset
|
656 |
FROM cw_Personne AS _X, cw_Personne AS _Y |
8345ee2c2ea6
[rql2sql] fix in 7394:d11d88bd08e8 was actually not needed
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7357
diff
changeset
|
657 |
WHERE _Y.cw_nom=_X.cw_nom AND _Y.cw_eid>_X.cw_eid'''), |
0 | 658 |
] |
659 |
||
5886 | 660 |
|
0 | 661 |
NEGATIONS = [ |
5886 | 662 |
|
0 | 663 |
("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
|
664 |
'''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
|
665 |
FROM cw_Personne AS _X |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
666 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_X.cw_eid))'''), |
1787 | 667 |
|
0 | 668 |
("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
|
669 |
'''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
|
670 |
FROM cw_Note AS _N |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
671 |
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 | 672 |
|
0 | 673 |
('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
|
674 |
'''SELECT _X.cw_eid |
e416186fb91c
prefix sql aliases for entity table by '_' to avoid pb with variable such as 'AS' (eg a keyword in SQL)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3752
diff
changeset
|
675 |
FROM cw_Personne AS _X |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
676 |
WHERE NOT (EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=_X.cw_eid))'''), |
1787 | 677 |
|
0 | 678 |
("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
|
679 |
'''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
|
680 |
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
|
681 |
WHERE NOT (DATE(_P.cw_datenaiss)=CURRENT_DATE)'''), |
1787 | 682 |
|
0 | 683 |
("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
|
684 |
'''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
|
685 |
FROM cw_Personne AS _P |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
686 |
WHERE NOT (EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_from=_P.cw_eid))'''), |
1787 | 687 |
|
0 | 688 |
("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
|
689 |
'''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
|
690 |
FROM cw_Affaire AS _A |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
691 |
WHERE NOT (EXISTS(SELECT 1 FROM concerne_relation AS rel_concerne0 WHERE rel_concerne0.eid_to=_A.cw_eid))'''), |
0 | 692 |
("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
|
693 |
'''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
|
694 |
FROM cw_Affaire AS _A, cw_Personne AS _P |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
695 |
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 | 696 |
|
697 |
('Any S WHERE NOT T eid 28258, T tags S', |
|
698 |
'''SELECT rel_tags0.eid_to |
|
699 |
FROM tags_relation AS rel_tags0 |
|
700 |
WHERE NOT (rel_tags0.eid_from=28258)'''), |
|
1787 | 701 |
|
0 | 702 |
('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
|
703 |
'''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
|
704 |
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
|
705 |
WHERE NOT (_T.cw_eid=28258) AND rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_S.cw_eid |
0 | 706 |
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
|
707 |
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
|
708 |
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
|
709 |
WHERE NOT (_T.cw_eid=28258) AND rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_S.cw_eid |
0 | 710 |
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
|
711 |
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
|
712 |
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
|
713 |
WHERE NOT (_T.cw_eid=28258) AND rel_tags0.eid_from=_T.cw_eid AND rel_tags0.eid_to=_S.cw_eid'''), |
0 | 714 |
|
715 |
('Any X,Y WHERE X created_by Y, X eid 5, NOT Y eid 6', |
|
716 |
'''SELECT 5, rel_created_by0.eid_to |
|
717 |
FROM created_by_relation AS rel_created_by0 |
|
718 |
WHERE rel_created_by0.eid_from=5 AND NOT (rel_created_by0.eid_to=6)'''), |
|
719 |
||
720 |
('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
|
721 |
'''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
|
722 |
FROM cw_Note AS _X |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
723 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_to=_X.cw_eid))'''), |
0 | 724 |
|
725 |
('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
|
726 |
'''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
|
727 |
FROM cw_CWUser AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
728 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_Y.cw_eid)) |
0 | 729 |
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
|
730 |
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
|
731 |
FROM cw_Division AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
732 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_Y.cw_eid)) |
0 | 733 |
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
|
734 |
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
|
735 |
FROM cw_Personne AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
736 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_Y.cw_eid)) |
0 | 737 |
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
|
738 |
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
|
739 |
FROM cw_Societe AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
740 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_Y.cw_eid)) |
0 | 741 |
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
|
742 |
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
|
743 |
FROM cw_SubDivision AS _Y |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
744 |
WHERE NOT (EXISTS(SELECT 1 FROM evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_Y.cw_eid))'''), |
0 | 745 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
746 |
('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
|
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_Note AS _X |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
749 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_CWUser AS _Y, evaluee_relation AS rel_evaluee0 WHERE rel_evaluee0.eid_from=_Y.cw_eid AND rel_evaluee0.eid_to=_X.cw_eid))'''), |
1787 | 750 |
|
3520
eb508952ee81
update test, record a failing test (commented out)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3245
diff
changeset
|
751 |
('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
|
752 |
'''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
|
753 |
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
|
754 |
WHERE _X.cw_relation_type IS NOT NULL'''), |
0 | 755 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
756 |
('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
|
757 |
'''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
|
758 |
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
|
759 |
WHERE _P.cw_for_user IS NULL'''), |
0 | 760 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
761 |
('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
|
762 |
'''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
|
763 |
FROM cw_State AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
764 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_Affaire AS _X WHERE _X.cw_in_state=_S.cw_eid UNION 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
|
765 |
|
eb508952ee81
update test, record a failing test (commented out)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3245
diff
changeset
|
766 |
('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
|
767 |
'''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
|
768 |
FROM cw_State AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
769 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_CWUser AS _X WHERE _X.cw_in_state=_S.cw_eid AND _S.cw_name=somename))'''), |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
770 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
771 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
772 |
HAS_TEXT_LG_INDEXER = [ |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
773 |
('Any X WHERE X has_text "toto tata"', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
774 |
"""SELECT DISTINCT appears0.uid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
775 |
FROM appears AS appears0 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
776 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
777 |
('Personne X WHERE X has_text "toto tata"', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
778 |
"""SELECT DISTINCT _X.eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
779 |
FROM appears AS appears0, entities AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
780 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=_X.eid AND _X.type='Personne'"""), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
781 |
('Personne X WHERE X has_text %(text)s', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
782 |
"""SELECT DISTINCT _X.eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
783 |
FROM appears AS appears0, entities AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
784 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('hip', 'hop', 'momo')) AND appears0.uid=_X.eid AND _X.type='Personne' |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
785 |
"""), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
786 |
('Any X WHERE X has_text "toto tata", X name "tutu", X is IN (Basket,Folder)', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
787 |
"""SELECT DISTINCT _X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
788 |
FROM appears AS appears0, cw_Basket AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
789 |
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 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
790 |
UNION |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
791 |
SELECT DISTINCT _X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
792 |
FROM appears AS appears0, cw_Folder AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
793 |
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""") |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
794 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
795 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
796 |
|
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
797 |
|
3520
eb508952ee81
update test, record a failing test (commented out)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3245
diff
changeset
|
798 |
# XXXFIXME fail |
eb508952ee81
update test, record a failing test (commented out)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3245
diff
changeset
|
799 |
# ('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
|
800 |
# '''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
|
801 |
# FROM cw_CWRelation AS _X'''), |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
802 |
|
0 | 803 |
|
804 |
OUTER_JOIN = [ |
|
805 |
('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
|
806 |
'''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
|
807 |
FROM cw_Personne AS _X LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_from=_X.cw_eid)''' |
0 | 808 |
), |
809 |
('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
|
810 |
'''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
|
811 |
FROM cw_Societe AS _S LEFT OUTER JOIN travaille_relation AS rel_travaille0 ON (rel_travaille0.eid_to=_S.cw_eid)''' |
0 | 812 |
), |
813 |
||
814 |
('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
|
815 |
'''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
|
816 |
FROM cw_Note AS _N'''), |
0 | 817 |
|
818 |
('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
|
819 |
'''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
|
820 |
FROM cw_TrInfo AS _X LEFT OUTER JOIN cw_State AS _S ON (_X.cw_from_state=_S.cw_eid)''' |
0 | 821 |
), |
822 |
||
823 |
('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
|
824 |
'''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
|
825 |
FROM cw_Affaire AS _A LEFT OUTER JOIN cw_Note AS _N ON (_N.cw_inline1=_A.cw_eid)''' |
0 | 826 |
), |
827 |
||
828 |
('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
|
829 |
'''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
|
830 |
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
|
831 |
WHERE _A.cw_eid=12'''), |
0 | 832 |
|
833 |
('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
|
834 |
'''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
|
835 |
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
|
836 |
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 | 837 |
ORDER BY 4 DESC'''), |
838 |
||
839 |
('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
|
840 |
'''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
|
841 |
FROM cw_Affaire AS _X |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
842 |
WHERE EXISTS(SELECT 1 FROM cw_CWUser AS _U, owned_by_relation AS rel_owned_by0, owned_by_relation AS rel_owned_by2, 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) 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 | 843 |
|
844 |
('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
|
845 |
'''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
|
846 |
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 | 847 |
), |
848 |
||
849 |
('Any A,C WHERE A documented_by C?, (C is NULL) OR (EXISTS(C require_permission F, ' |
|
850 |
'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
|
851 |
'''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
|
852 |
FROM cw_Affaire AS _A LEFT OUTER JOIN documented_by_relation AS rel_documented_by0 ON (rel_documented_by0.eid_from=_A.cw_eid) |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
853 |
WHERE ((rel_documented_by0.eid_to IS NULL) OR (EXISTS(SELECT 1 FROM cw_CWPermission AS _F, in_group_relation AS rel_in_group3, require_group_relation AS rel_require_group2, require_permission_relation AS rel_require_permission1 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 | 854 |
|
855 |
("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
|
856 |
'''SELECT _X.cw_eid |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
857 |
FROM cw_Personne AS _X LEFT OUTER JOIN connait_relation AS rel_connait0 ON (rel_connait0.eid_to=_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
|
858 |
WHERE _X.cw_eid=12''' |
0 | 859 |
), |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
860 |
("Any P WHERE X eid 12, P? concerne X, X todo_by S", |
7357
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
861 |
'''SELECT rel_concerne1.eid_from |
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
862 |
FROM todo_by_relation AS rel_todo_by0 LEFT OUTER JOIN concerne_relation AS rel_concerne1 ON (rel_concerne1.eid_to=12) |
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
863 |
WHERE rel_todo_by0.eid_from=12''' |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
864 |
), |
0 | 865 |
|
866 |
('Any GN, TN ORDERBY GN WHERE T tags G?, T name TN, G name GN', |
|
1787 | 867 |
''' |
3762
e416186fb91c
prefix sql aliases for entity table by '_' 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 |
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
|
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 (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
|
870 |
FROM cw_CWGroup AS _G |
0 | 871 |
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
|
872 |
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
|
873 |
FROM cw_State AS _G |
0 | 874 |
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
|
875 |
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
|
876 |
FROM cw_Tag AS _G) AS _T0 ON (rel_tags0.eid_to=_T0.C0) |
0 | 877 |
ORDER BY 1'''), |
878 |
||
879 |
||
880 |
# 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
|
881 |
('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
|
882 |
'''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
|
883 |
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 | 884 |
|
885 |
# optional variable with additional invariant restriction |
|
886 |
('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
|
887 |
'''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
|
888 |
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 | 889 |
|
890 |
# 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
|
891 |
('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
|
892 |
'''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
|
893 |
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 | 894 |
|
895 |
# optional variable with additional restriction on inlined relation |
|
896 |
# 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
|
897 |
('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
|
898 |
'''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
|
899 |
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
|
900 |
WHERE _G.cw_in_state=_S.cw_eid AND _S.cw_name=hop |
0 | 901 |
'''), |
902 |
||
903 |
# 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
|
904 |
('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
|
905 |
'''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
|
906 |
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
|
907 |
WHERE rel_tags0.eid_to=_G.cw_eid AND (_G.cw_in_state=1 OR _G.cw_in_state IS NULL)'''), |
0 | 908 |
|
909 |
# 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
|
910 |
('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
|
911 |
'''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
|
912 |
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 | 913 |
|
914 |
# 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
|
915 |
('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
|
916 |
'''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
|
917 |
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 | 918 |
|
0 | 919 |
# two optional variables with additional restriction on an ambigous inlined relation |
920 |
('Any T,G,S WHERE T tags G?, G in_state S?, S name "hop"', |
|
1787 | 921 |
''' |
3762
e416186fb91c
prefix sql aliases for entity table by '_' 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 |
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
|
923 |
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
|
924 |
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 | 925 |
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
|
926 |
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
|
927 |
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 | 928 |
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
|
929 |
SELECT _G.cw_eid AS C0, _S.cw_eid AS C1 |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
930 |
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 | 931 |
|
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
|
932 |
('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
|
933 |
'''SELECT _O.cw_eid, rel_todo_by0.eid_to |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
934 |
FROM cw_Note AS _S, cw_Affaire AS _O LEFT OUTER JOIN todo_by_relation AS rel_todo_by0 ON (rel_todo_by0.eid_from=_O.cw_eid) |
7252
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
935 |
WHERE (_S.cw_inline1 IS NULL OR _S.cw_inline1!=_O.cw_eid) AND _S.cw_eid=123'''), |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
936 |
|
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
937 |
('Any X,AE WHERE X multisource_inlined_rel S?, S ambiguous_inlined A, A modification_date AE', |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
938 |
'''SELECT _X.cw_eid, _T0.C2 |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
939 |
FROM cw_Card AS _X LEFT OUTER JOIN (SELECT _S.cw_eid AS C0, _A.cw_eid AS C1, _A.cw_modification_date AS C2 |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
940 |
FROM cw_Affaire AS _S, cw_CWUser AS _A |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
941 |
WHERE _S.cw_ambiguous_inlined=_A.cw_eid |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
942 |
UNION ALL |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
943 |
SELECT _S.cw_eid AS C0, _A.cw_eid AS C1, _A.cw_modification_date AS C2 |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
944 |
FROM cw_CWUser AS _A, cw_Note AS _S |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
945 |
WHERE _S.cw_ambiguous_inlined=_A.cw_eid) AS _T0 ON (_X.cw_multisource_inlined_rel=_T0.C0) |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
946 |
UNION ALL |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
947 |
SELECT _X.cw_eid, _T0.C2 |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
948 |
FROM cw_Note AS _X LEFT OUTER JOIN (SELECT _S.cw_eid AS C0, _A.cw_eid AS C1, _A.cw_modification_date AS C2 |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
949 |
FROM cw_Affaire AS _S, cw_CWUser AS _A |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
950 |
WHERE _S.cw_ambiguous_inlined=_A.cw_eid |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
951 |
UNION ALL |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
952 |
SELECT _S.cw_eid AS C0, _A.cw_eid AS C1, _A.cw_modification_date AS C2 |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
953 |
FROM cw_CWUser AS _A, cw_Note AS _S |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
954 |
WHERE _S.cw_ambiguous_inlined=_A.cw_eid) AS _T0 ON (_X.cw_multisource_inlined_rel=_T0.C0)''' |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
955 |
), |
adb1673efa5f
[sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7194
diff
changeset
|
956 |
|
7357
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
957 |
('Any X,T,OT WHERE X tags T, OT? tags X, X is Tag, X eid 123', |
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
958 |
'''SELECT rel_tags0.eid_from, rel_tags0.eid_to, rel_tags1.eid_from |
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
959 |
FROM tags_relation AS rel_tags0 LEFT OUTER JOIN tags_relation AS rel_tags1 ON (rel_tags1.eid_to=123) |
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
960 |
WHERE rel_tags0.eid_from=123'''), |
0 | 961 |
] |
962 |
||
963 |
VIRTUAL_VARS = [ |
|
3815
50b87f759b5d
test and fix http://www.logilab.org/ticket/499838
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3762
diff
changeset
|
964 |
|
50b87f759b5d
test and fix http://www.logilab.org/ticket/499838
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3762
diff
changeset
|
965 |
('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
|
966 |
'''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
|
967 |
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
|
968 |
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
|
969 |
|
50b87f759b5d
test and fix http://www.logilab.org/ticket/499838
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3762
diff
changeset
|
970 |
('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
|
971 |
'''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
|
972 |
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
|
973 |
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
|
974 |
|
50b87f759b5d
test and fix http://www.logilab.org/ticket/499838
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3762
diff
changeset
|
975 |
('Personne P WHERE P travaille S, S tel T, S fax T, S is Societe', |
0 | 976 |
'''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
|
977 |
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
|
978 |
WHERE rel_travaille0.eid_to=_S.cw_eid AND _S.cw_tel=_S.cw_fax'''), |
1787 | 979 |
|
0 | 980 |
("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
|
981 |
'''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
|
982 |
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
|
983 |
WHERE _X.cw_eid=0 AND _P.cw_datenaiss<_X.cw_creation_date'''), |
0 | 984 |
|
985 |
("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
|
986 |
'''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
|
987 |
FROM cw_Note AS _N'''), |
0 | 988 |
|
989 |
("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
|
990 |
'''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
|
991 |
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
|
992 |
WHERE _P.cw_fax=(_X.cw_tel + _X.cw_fax)'''), |
0 | 993 |
|
994 |
("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
|
995 |
'''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
|
996 |
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
|
997 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax) |
0 | 998 |
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
|
999 |
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
|
1000 |
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
|
1001 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax) |
0 | 1002 |
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
|
1003 |
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
|
1004 |
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
|
1005 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax) |
0 | 1006 |
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
|
1007 |
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
|
1008 |
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
|
1009 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax)'''), |
0 | 1010 |
|
1011 |
("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
|
1012 |
'''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
|
1013 |
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
|
1014 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax, 832542332) |
0 | 1015 |
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
|
1016 |
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
|
1017 |
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
|
1018 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax, 832542332) |
0 | 1019 |
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
|
1020 |
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
|
1021 |
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
|
1022 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax, 832542332) |
0 | 1023 |
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
|
1024 |
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
|
1025 |
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
|
1026 |
WHERE _P.cw_fax IN(_X.cw_tel, _X.cw_fax, 832542332)'''), |
0 | 1027 |
] |
1028 |
||
1029 |
FUNCS = [ |
|
1030 |
("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
|
1031 |
'''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
|
1032 |
FROM cw_Personne AS _P'''), |
0 | 1033 |
] |
1034 |
||
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1035 |
SYMMETRIC = [ |
0 | 1036 |
('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
|
1037 |
'''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
|
1038 |
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
|
1039 |
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 | 1040 |
), |
1787 | 1041 |
|
0 | 1042 |
('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
|
1043 |
'''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
|
1044 |
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
|
1045 |
WHERE (rel_connait0.eid_to=_P.cw_eid OR rel_connait0.eid_from=_P.cw_eid)''' |
0 | 1046 |
), |
1787 | 1047 |
|
0 | 1048 |
('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
|
1049 |
'''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
|
1050 |
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
|
1051 |
WHERE (rel_connait0.eid_from=_X.cw_eid OR rel_connait0.eid_to=_X.cw_eid)''' |
0 | 1052 |
), |
1787 | 1053 |
|
0 | 1054 |
('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
|
1055 |
'''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
|
1056 |
FROM cw_Personne AS _P |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1057 |
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 | 1058 |
|
0 | 1059 |
('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
|
1060 |
'''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
|
1061 |
FROM cw_Personne AS _P |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1062 |
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 | 1063 |
|
0 | 1064 |
('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
|
1065 |
'''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
|
1066 |
FROM cw_Personne AS _X |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1067 |
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 | 1068 |
|
1069 |
('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
|
1070 |
'''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
|
1071 |
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
|
1072 |
WHERE (rel_connait0.eid_to=_P.cw_eid OR rel_connait0.eid_from=_P.cw_eid) AND _P.cw_nom=nom'''), |
1787 | 1073 |
|
0 | 1074 |
('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
|
1075 |
'''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
|
1076 |
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
|
1077 |
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 | 1078 |
), |
1079 |
||
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1080 |
('DISTINCT Any P WHERE P connait S OR S connait P, S nom "chouette"', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1081 |
'''SELECT DISTINCT _P.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1082 |
FROM connait_relation AS rel_connait0, cw_Personne AS _P, cw_Personne AS _S |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1083 |
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''' |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1084 |
) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1085 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1086 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1087 |
SYMMETRIC_WITH_LIMIT = [ |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1088 |
('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
|
1089 |
'''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
|
1090 |
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
|
1091 |
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 | 1092 |
ORDER BY 1 DESC |
1093 |
LIMIT 9''' |
|
1094 |
), |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1095 |
] |
0 | 1096 |
|
1097 |
INLINE = [ |
|
5844
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1098 |
|
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1099 |
('Any P WHERE N eid 1, N ecrit_par P, NOT P owned_by P2', |
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1100 |
'''SELECT _N.cw_ecrit_par |
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1101 |
FROM cw_Note AS _N |
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1102 |
WHERE _N.cw_eid=1 AND _N.cw_ecrit_par IS NOT NULL AND NOT (EXISTS(SELECT 1 FROM owned_by_relation AS rel_owned_by0 WHERE _N.cw_ecrit_par=rel_owned_by0.eid_from))'''), |
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1103 |
|
0 | 1104 |
('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
|
1105 |
'''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
|
1106 |
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
|
1107 |
WHERE _N.cw_ecrit_par=_P.cw_eid AND _N.cw_eid=0'''), |
1787 | 1108 |
|
0 | 1109 |
('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
|
1110 |
'''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
|
1111 |
FROM cw_Note AS _N, cw_Personne AS _P |
6003
5fbc1c4c13ff
[rql2sql] fix bug with NOT of inlined relation: NULL values are not properly handled and hence some rows won't be returned while the should
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5901
diff
changeset
|
1112 |
WHERE (_N.cw_ecrit_par IS NULL OR _N.cw_ecrit_par!=_P.cw_eid) AND _P.cw_nom=toto'''), |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1113 |
|
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1114 |
('Any P WHERE NOT N ecrit_par P, P nom "toto"', |
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1115 |
'''SELECT _P.cw_eid |
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1116 |
FROM cw_Personne AS _P |
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1117 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_Note AS _N WHERE _N.cw_ecrit_par=_P.cw_eid)) AND _P.cw_nom=toto'''), |
1787 | 1118 |
|
0 | 1119 |
('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
|
1120 |
'''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
|
1121 |
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
|
1122 |
WHERE _N.cw_ecrit_par IS NOT NULL AND _N.cw_eid=0'''), |
0 | 1123 |
|
1124 |
('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
|
1125 |
'''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
|
1126 |
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
|
1127 |
WHERE _N.cw_ecrit_par=_P.cw_eid AND _N.cw_eid=0'''), |
0 | 1128 |
|
1129 |
('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
|
1130 |
'''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
|
1131 |
FROM cw_Note AS _N, cw_Personne AS _P |
6003
5fbc1c4c13ff
[rql2sql] fix bug with NOT of inlined relation: NULL values are not properly handled and hence some rows won't be returned while the should
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5901
diff
changeset
|
1132 |
WHERE (_N.cw_ecrit_par IS NULL OR _N.cw_ecrit_par!=_P.cw_eid) AND _N.cw_eid=512'''), |
0 | 1133 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1134 |
('Any S,ES,T WHERE S state_of ET, ET name "CWUser", ES allowed_transition T, T destination_state S', |
5844
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1135 |
# XXX "_T.cw_destination_state IS NOT NULL" could be avoided here but it's not worth it |
3762
e416186fb91c
prefix sql aliases for entity table by '_' to avoid pb with variable such as 'AS' (eg a keyword in SQL)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3752
diff
changeset
|
1136 |
'''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
|
1137 |
FROM allowed_transition_relation AS rel_allowed_transition1, cw_Transition AS _T, cw_Workflow AS _ET, state_of_relation AS rel_state_of0 |
5844
df7608ecea29
[sql generation] fix bug with inlined relation and referenced by other neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5793
diff
changeset
|
1138 |
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 AND _T.cw_destination_state IS NOT NULL'''), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2916
diff
changeset
|
1139 |
|
0 | 1140 |
('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
|
1141 |
'''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
|
1142 |
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
|
1143 |
WHERE _S.cw_eid=0 AND _S.cw_in_state IS NOT NULL |
0 | 1144 |
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
|
1145 |
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
|
1146 |
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
|
1147 |
WHERE _S.cw_eid=0 AND _S.cw_in_state IS NOT NULL |
0 | 1148 |
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
|
1149 |
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
|
1150 |
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
|
1151 |
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
|
1152 |
|
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
|
1153 |
('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
|
1154 |
'''SELECT 123 |
5898
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1155 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_CWProperty AS _Y WHERE _Y.cw_for_user=123))'''), |
1787 | 1156 |
|
5898
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1157 |
('DISTINCT Any X WHERE X from_entity OET, NOT X from_entity NET, OET name "Image", NET eid 1', |
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1158 |
'''SELECT DISTINCT _X.cw_eid |
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1159 |
FROM cw_CWAttribute AS _X, cw_CWEType AS _OET |
6003
5fbc1c4c13ff
[rql2sql] fix bug with NOT of inlined relation: NULL values are not properly handled and hence some rows won't be returned while the should
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5901
diff
changeset
|
1160 |
WHERE _X.cw_from_entity=_OET.cw_eid AND (_X.cw_from_entity IS NULL OR _X.cw_from_entity!=1) AND _OET.cw_name=Image |
5898
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1161 |
UNION |
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1162 |
SELECT DISTINCT _X.cw_eid |
5630bd8f98d9
imported patch rql2sqlfix.diff
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5887
diff
changeset
|
1163 |
FROM cw_CWEType AS _OET, cw_CWRelation AS _X |
6003
5fbc1c4c13ff
[rql2sql] fix bug with NOT of inlined relation: NULL values are not properly handled and hence some rows won't be returned while the should
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5901
diff
changeset
|
1164 |
WHERE _X.cw_from_entity=_OET.cw_eid AND (_X.cw_from_entity IS NULL OR _X.cw_from_entity!=1) AND _OET.cw_name=Image'''), |
5fbc1c4c13ff
[rql2sql] fix bug with NOT of inlined relation: NULL values are not properly handled and hence some rows won't be returned while the should
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5901
diff
changeset
|
1165 |
|
0 | 1166 |
] |
1167 |
||
438 | 1168 |
INTERSECT = [ |
1169 |
('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
|
1170 |
'''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
|
1171 |
FROM cw_State AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1172 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_Affaire AS _X WHERE _X.cw_in_state=_S.cw_eid UNION SELECT 1 FROM cw_Note AS _X WHERE _X.cw_in_state=_S.cw_eid UNION SELECT 1 FROM cw_CWUser AS _X WHERE _X.cw_in_state=_S.cw_eid))'''), |
0 | 1173 |
|
438 | 1174 |
('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
|
1175 |
'''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
|
1176 |
FROM cw_Personne AS _X |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1177 |
WHERE NOT (EXISTS(SELECT 1 FROM cw_Division AS _S, travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_from=_X.cw_eid AND rel_travaille0.eid_to=_S.cw_eid UNION SELECT 1 FROM cw_Societe AS _S, travaille_relation AS rel_travaille1 WHERE rel_travaille1.eid_from=_X.cw_eid AND rel_travaille1.eid_to=_S.cw_eid))'''), |
1787 | 1178 |
|
438 | 1179 |
('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
|
1180 |
'''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
|
1181 |
FROM cw_Division AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1182 |
WHERE NOT (EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=_S.cw_eid)) |
438 | 1183 |
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
|
1184 |
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
|
1185 |
FROM cw_Societe AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1186 |
WHERE NOT (EXISTS(SELECT 1 FROM travaille_relation AS rel_travaille0 WHERE rel_travaille0.eid_to=_S.cw_eid))'''), |
1787 | 1187 |
|
438 | 1188 |
('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
|
1189 |
'''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
|
1190 |
FROM cw_Division AS _S, cw_Personne AS _X |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1191 |
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 | 1192 |
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
|
1193 |
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
|
1194 |
FROM cw_Personne AS _X, cw_Societe AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1195 |
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 | 1196 |
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
|
1197 |
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
|
1198 |
FROM cw_Personne AS _X, cw_SubDivision AS _S |
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1199 |
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 | 1200 |
|
438 | 1201 |
('Any X WHERE X is ET, ET eid 2', |
1202 |
'''SELECT rel_is0.eid_from |
|
1203 |
FROM is_relation AS rel_is0 |
|
1204 |
WHERE rel_is0.eid_to=2'''), |
|
1205 |
||
1206 |
] |
|
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
|
1207 |
class CWRQLTC(RQLGeneratorTC): |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1208 |
backend = 'sqlite' |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1209 |
|
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1210 |
def setUp(self): |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1211 |
self.__class__.schema = schema |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1212 |
super(CWRQLTC, self).setUp() |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1213 |
|
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
|
1214 |
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
|
1215 |
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
|
1216 |
'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
|
1217 |
'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
|
1218 |
'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
|
1219 |
'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
|
1220 |
'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
|
1221 |
'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
|
1222 |
'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
|
1223 |
'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
|
1224 |
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
|
1225 |
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
|
1226 |
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
|
1227 |
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
|
1228 |
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
|
1229 |
return s |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1230 |
self.assertEqual(var_sols('FROM_ENTITYOBJECT'), set(('CWAttribute', 'CWRelation'))) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1231 |
self.assertEqual(var_sols('FROM_ENTITYOBJECT'), delete.defined_vars['FROM_ENTITYOBJECT'].stinfo['possibletypes']) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1232 |
self.assertEqual(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
|
1233 |
set(x.type for x in self.schema.entities() if not x.final)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1234 |
self.assertEqual(var_sols('ISOBJECT'), delete.defined_vars['ISOBJECT'].stinfo['possibletypes']) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1235 |
|
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
|
1236 |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1237 |
def strip(text): |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1238 |
return '\n'.join(l.strip() for l in text.strip().splitlines()) |
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
|
1239 |
|
0 | 1240 |
class PostgresSQLGeneratorTC(RQLGeneratorTC): |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1241 |
backend = 'postgres' |
0 | 1242 |
|
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1243 |
def setUp(self): |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1244 |
self.__class__.schema = schema |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1245 |
super(PostgresSQLGeneratorTC, self).setUp() |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6493
diff
changeset
|
1246 |
|
0 | 1247 |
def _norm_sql(self, sql): |
1248 |
return sql.strip() |
|
1787 | 1249 |
|
2071
6ebada01a4a1
new test for missing from close when using a var map
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
1250 |
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
|
1251 |
if args is None: |
7596
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1252 |
args = {'text': 'hip hop momo', 'eid': 12345} |
0 | 1253 |
try: |
1254 |
union = self._prepare(rql) |
|
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1255 |
r, nargs, cbs = self.o.generate(union, args, |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1256 |
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
|
1257 |
args.update(nargs) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1258 |
self.assertMultiLineEqual(strip(r % args), self._norm_sql(sql)) |
0 | 1259 |
except Exception, ex: |
1260 |
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
|
1261 |
try: |
6ebada01a4a1
new test for missing from close when using a var map
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
1262 |
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
|
1263 |
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
|
1264 |
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
|
1265 |
print r, nargs |
0 | 1266 |
print '!=' |
1267 |
print sql.strip() |
|
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1268 |
print 'RQL:', rql |
0 | 1269 |
raise |
1787 | 1270 |
|
0 | 1271 |
def _parse(self, rqls): |
1272 |
for rql, sql in rqls: |
|
1273 |
yield self._check, rql, sql |
|
1787 | 1274 |
|
0 | 1275 |
def _checkall(self, rql, sql): |
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1276 |
if isinstance(rql, tuple): |
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1277 |
rql, args = rql |
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1278 |
else: |
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1279 |
args = None |
0 | 1280 |
try: |
1281 |
rqlst = self._prepare(rql) |
|
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1282 |
r, args, cbs = self.o.generate(rqlst, args) |
0 | 1283 |
self.assertEqual((r.strip(), args), sql) |
1284 |
except Exception, ex: |
|
1285 |
print rql |
|
1286 |
if 'r' in locals(): |
|
1287 |
print r.strip() |
|
1288 |
print '!=' |
|
1289 |
print sql[0].strip() |
|
1290 |
raise |
|
1291 |
return |
|
1292 |
||
1293 |
def test1(self): |
|
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1294 |
self._checkall(('Any count(RDEF) WHERE RDEF relation_type X, X eid %(x)s', {'x': None}), |
3762
e416186fb91c
prefix sql aliases for entity table by '_' 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 |
("""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
|
1296 |
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
|
1297 |
WHERE _RDEF.cw_relation_type=%(x)s |
0 | 1298 |
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
|
1299 |
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
|
1300 |
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
|
1301 |
WHERE _RDEF.cw_relation_type=%(x)s) AS T1""", {}), |
0 | 1302 |
) |
1303 |
||
1304 |
def test2(self): |
|
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1305 |
self._checkall(('Any X WHERE C comments X, C eid %(x)s', {'x': None}), |
0 | 1306 |
('''SELECT rel_comments0.eid_to |
1307 |
FROM comments_relation AS rel_comments0 |
|
1308 |
WHERE rel_comments0.eid_from=%(x)s''', {}) |
|
1309 |
) |
|
1310 |
||
1311 |
def test_cache_1(self): |
|
1312 |
self._check('Any X WHERE X in_basket B, B eid 12', |
|
1313 |
'''SELECT rel_in_basket0.eid_from |
|
1314 |
FROM in_basket_relation AS rel_in_basket0 |
|
1315 |
WHERE rel_in_basket0.eid_to=12''') |
|
1787 | 1316 |
|
0 | 1317 |
self._check('Any X WHERE X in_basket B, B eid 12', |
1318 |
'''SELECT rel_in_basket0.eid_from |
|
1319 |
FROM in_basket_relation AS rel_in_basket0 |
|
1320 |
WHERE rel_in_basket0.eid_to=12''') |
|
1321 |
||
2071
6ebada01a4a1
new test for missing from close when using a var map
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
1322 |
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
|
1323 |
self._check('Any X,L WHERE X is CWUser, X in_group G, X login L, G name "users"', |
0 | 1324 |
'''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
|
1325 |
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
|
1326 |
WHERE rel_in_group0.eid_from=T00.x AND rel_in_group0.eid_to=_G.cw_eid AND _G.cw_name=users''', |
0 | 1327 |
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
|
1328 |
|
6ebada01a4a1
new test for missing from close when using a var map
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
1329 |
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
|
1330 |
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
|
1331 |
'''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
|
1332 |
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
|
1333 |
WHERE rel_in_group0.eid_from=T00.x AND rel_in_group0.eid_to=_G.cw_eid''', |
0 | 1334 |
varmap={'X': 'T00.x', 'X.login': 'T00.l'}) |
1335 |
||
2071
6ebada01a4a1
new test for missing from close when using a var map
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
1336 |
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
|
1337 |
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
|
1338 |
'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
|
1339 |
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
|
1340 |
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
|
1341 |
|
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
|
1342 |
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
|
1343 |
union = self._prepare('Any X WHERE X login %(login)s') |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1344 |
r, args, cbs = self.o.generate(union, {'login': None}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1345 |
self.assertMultiLineEqual((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
|
1346 |
'''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
|
1347 |
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
|
1348 |
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
|
1349 |
|
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
|
1350 |
|
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
|
1351 |
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
|
1352 |
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
|
1353 |
'''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
|
1354 |
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
|
1355 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
1356 |
def test_substring(self): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
1357 |
self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne", |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
1358 |
'''SELECT SUBSTR(_P.cw_nom, 1, 1) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
1359 |
FROM cw_Personne AS _P''') |
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
|
1360 |
|
7256
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1361 |
def test_cast(self): |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1362 |
self._check("Any CAST(String, P) WHERE P is Personne", |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1363 |
'''SELECT CAST(_P.cw_eid AS text) |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1364 |
FROM cw_Personne AS _P''') |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1365 |
|
7257
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1366 |
def test_regexp(self): |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1367 |
self._check("Any X WHERE X login REGEXP '[0-9].*'", |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1368 |
'''SELECT _X.cw_eid |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1369 |
FROM cw_CWUser AS _X |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1370 |
WHERE _X.cw_login ~ [0-9].* |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1371 |
''') |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1372 |
|
0 | 1373 |
def test_parser_parse(self): |
1374 |
for t in self._parse(PARSER): |
|
1375 |
yield t |
|
1787 | 1376 |
|
0 | 1377 |
def test_basic_parse(self): |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1378 |
for t in self._parse(BASIC + BASIC_WITH_LIMIT): |
0 | 1379 |
yield t |
1380 |
||
1381 |
def test_advanced_parse(self): |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1382 |
for t in self._parse(ADVANCED + ADVANCED_WITH_LIMIT_OR_ORDERBY + ADVANCED_WITH_GROUP_CONCAT): |
0 | 1383 |
yield t |
1384 |
||
1385 |
def test_outer_join_parse(self): |
|
1386 |
for t in self._parse(OUTER_JOIN): |
|
1387 |
yield t |
|
1388 |
||
1389 |
def test_virtual_vars_parse(self): |
|
1390 |
for t in self._parse(VIRTUAL_VARS): |
|
1391 |
yield t |
|
1392 |
||
1393 |
def test_multiple_sel_parse(self): |
|
1394 |
for t in self._parse(MULTIPLE_SEL): |
|
1395 |
yield t |
|
1787 | 1396 |
|
0 | 1397 |
def test_functions(self): |
1398 |
for t in self._parse(FUNCS): |
|
1399 |
yield t |
|
1787 | 1400 |
|
0 | 1401 |
def test_negation(self): |
1402 |
for t in self._parse(NEGATIONS): |
|
1403 |
yield t |
|
1787 | 1404 |
|
438 | 1405 |
def test_intersection(self): |
1406 |
for t in self._parse(INTERSECT): |
|
1407 |
yield t |
|
0 | 1408 |
|
1409 |
def test_union(self): |
|
1410 |
for t in self._parse(( |
|
1411 |
('(Any N ORDERBY 1 WHERE X name N, X is State)' |
|
1412 |
' UNION ' |
|
1413 |
'(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
|
1414 |
'''(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
|
1415 |
FROM cw_State AS _X |
0 | 1416 |
ORDER BY 1) |
1417 |
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
|
1418 |
(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
|
1419 |
FROM cw_Transition AS _XX |
0 | 1420 |
ORDER BY 1)'''), |
1421 |
)): |
|
1422 |
yield t |
|
1787 | 1423 |
|
0 | 1424 |
def test_subquery(self): |
1425 |
for t in self._parse(( |
|
1426 |
||
1427 |
('Any N ORDERBY 1 WITH N BEING ' |
|
1428 |
'((Any N WHERE X name N, X is State)' |
|
1429 |
' UNION ' |
|
1430 |
'(Any NN WHERE XX name NN, XX is Transition))', |
|
1431 |
'''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
|
1432 |
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
|
1433 |
FROM cw_State AS _X) |
0 | 1434 |
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
|
1435 |
(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
|
1436 |
FROM cw_Transition AS _XX)) AS _T0 |
0 | 1437 |
ORDER BY 1'''), |
1787 | 1438 |
|
0 | 1439 |
('Any N,NX ORDERBY NX WITH N,NX BEING ' |
1440 |
'((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
|
1441 |
' UNION ' |
|
1442 |
'(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
|
1443 |
'''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
|
1444 |
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
|
1445 |
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
|
1446 |
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
|
1447 |
HAVING COUNT(_X.cw_eid)>1) |
0 | 1448 |
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
|
1449 |
(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
|
1450 |
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
|
1451 |
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
|
1452 |
HAVING COUNT(_X.cw_eid)>1)) AS _T0 |
1787 | 1453 |
ORDER BY 2'''), |
0 | 1454 |
|
1455 |
('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
|
1456 |
'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
|
1457 |
' (Any X, N WHERE X name N, X is Transition))', |
|
1458 |
'''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
|
1459 |
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
|
1460 |
FROM cw_State AS _X) |
0 | 1461 |
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
|
1462 |
(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
|
1463 |
FROM cw_Transition AS _X)) AS _T0 |
0 | 1464 |
GROUP BY _T0.C1 |
1465 |
HAVING COUNT(_T0.C0)>1'''), |
|
1466 |
||
1467 |
('Any ETN,COUNT(X) GROUPBY ETN WHERE X is ET, ET name ETN ' |
|
1468 |
'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
|
1469 |
'''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
|
1470 |
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
|
1471 |
FROM cw_Societe AS _X) |
0 | 1472 |
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
|
1473 |
(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
|
1474 |
FROM cw_Affaire AS _X |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1475 |
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 owned_by_relation AS rel_owned_by2, 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) 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 owned_by_relation AS rel_owned_by4, 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) 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 |
3762
e416186fb91c
prefix sql aliases for entity table by '_' 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 |
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
|
1477 |
GROUP BY _ET.cw_name'''), |
7472
9833c09460f1
[rql2sql] fix missing sql restriction w/ attribute restriction where value comes from a subquery
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7421
diff
changeset
|
1478 |
|
9833c09460f1
[rql2sql] fix missing sql restriction w/ attribute restriction where value comes from a subquery
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7421
diff
changeset
|
1479 |
('Any A WHERE A ordernum O, A is CWAttribute WITH O BEING (Any MAX(O) WHERE A ordernum O, A is CWAttribute)', |
9833c09460f1
[rql2sql] fix missing sql restriction w/ attribute restriction where value comes from a subquery
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7421
diff
changeset
|
1480 |
'''SELECT _A.cw_eid |
9833c09460f1
[rql2sql] fix missing sql restriction w/ attribute restriction where value comes from a subquery
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7421
diff
changeset
|
1481 |
FROM (SELECT MAX(_A.cw_ordernum) AS C0 |
9833c09460f1
[rql2sql] fix missing sql restriction w/ attribute restriction where value comes from a subquery
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7421
diff
changeset
|
1482 |
FROM cw_CWAttribute AS _A) AS _T0, cw_CWAttribute AS _A |
9833c09460f1
[rql2sql] fix missing sql restriction w/ attribute restriction where value comes from a subquery
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7421
diff
changeset
|
1483 |
WHERE _A.cw_ordernum=_T0.C0'''), |
0 | 1484 |
)): |
1485 |
yield t |
|
1486 |
||
1787 | 1487 |
|
0 | 1488 |
def test_subquery_error(self): |
1489 |
rql = ('Any N WHERE X name N WITH X BEING ' |
|
1490 |
'((Any X WHERE X is State)' |
|
1491 |
' UNION ' |
|
1492 |
' (Any X WHERE X is Transition))') |
|
1493 |
rqlst = self._prepare(rql) |
|
1494 |
self.assertRaises(BadRQLQuery, self.o.generate, rqlst) |
|
1787 | 1495 |
|
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
|
1496 |
def test_symmetric(self): |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1497 |
for t in self._parse(SYMMETRIC + SYMMETRIC_WITH_LIMIT): |
0 | 1498 |
yield t |
1787 | 1499 |
|
0 | 1500 |
def test_inline(self): |
1501 |
for t in self._parse(INLINE): |
|
1502 |
yield t |
|
1787 | 1503 |
|
0 | 1504 |
def test_has_text(self): |
1505 |
for t in self._parse(( |
|
1506 |
('Any X WHERE X has_text "toto tata"', |
|
1507 |
"""SELECT appears0.uid |
|
1508 |
FROM appears AS appears0 |
|
1509 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata')"""), |
|
1787 | 1510 |
|
0 | 1511 |
('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
|
1512 |
"""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
|
1513 |
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
|
1514 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.eid AND _X.type='Personne'"""), |
1787 | 1515 |
|
0 | 1516 |
('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
|
1517 |
"""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
|
1518 |
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
|
1519 |
WHERE appears0.words @@ to_tsquery('default', 'hip&hop&momo') AND appears0.uid=_X.eid AND _X.type='Personne'"""), |
1787 | 1520 |
|
3587 | 1521 |
('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
|
1522 |
"""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
|
1523 |
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
|
1524 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu |
0 | 1525 |
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
|
1526 |
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
|
1527 |
FROM appears AS appears0, cw_Folder AS _X |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1528 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu"""), |
0 | 1529 |
|
1530 |
('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
|
1531 |
"""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
|
1532 |
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
|
1533 |
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')"""), |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1534 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1535 |
('Any X ORDERBY FTIRANK(X) DESC WHERE X has_text "toto tata"', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1536 |
"""SELECT appears0.uid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1537 |
FROM appears AS appears0 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1538 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1539 |
ORDER BY ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight DESC"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1540 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1541 |
('Personne X ORDERBY FTIRANK(X) WHERE X has_text "toto tata"', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1542 |
"""SELECT _X.eid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1543 |
FROM appears AS appears0, entities AS _X |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1544 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.eid AND _X.type='Personne' |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1545 |
ORDER BY ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1546 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1547 |
('Personne X ORDERBY FTIRANK(X) WHERE X has_text %(text)s', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1548 |
"""SELECT _X.eid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1549 |
FROM appears AS appears0, entities AS _X |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1550 |
WHERE appears0.words @@ to_tsquery('default', 'hip&hop&momo') AND appears0.uid=_X.eid AND _X.type='Personne' |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1551 |
ORDER BY ts_rank(appears0.words, to_tsquery('default', 'hip&hop&momo'))*appears0.weight"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1552 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1553 |
('Any X ORDERBY FTIRANK(X) WHERE X has_text "toto tata", X name "tutu", X is IN (Basket,Folder)', |
7587
c7c0f53062f5
[rql2sql tests] fix erroneous case (tested with psql)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7579
diff
changeset
|
1554 |
"""SELECT T1.C0 FROM (SELECT _X.cw_eid AS C0, ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight AS C1 |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1555 |
FROM appears AS appears0, cw_Basket AS _X |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1556 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1557 |
UNION ALL |
7587
c7c0f53062f5
[rql2sql tests] fix erroneous case (tested with psql)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7579
diff
changeset
|
1558 |
SELECT _X.cw_eid AS C0, ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight AS C1 |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1559 |
FROM appears AS appears0, cw_Folder AS _X |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1560 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu |
7587
c7c0f53062f5
[rql2sql tests] fix erroneous case (tested with psql)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7579
diff
changeset
|
1561 |
ORDER BY 2) AS T1"""), |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1562 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1563 |
('Personne X ORDERBY FTIRANK(X),FTIRANK(S) WHERE X has_text %(text)s, X travaille S, S has_text %(text)s', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1564 |
"""SELECT _X.eid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1565 |
FROM appears AS appears0, appears AS appears2, entities AS _X, travaille_relation AS rel_travaille1 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1566 |
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') |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1567 |
ORDER BY ts_rank(appears0.words, to_tsquery('default', 'hip&hop&momo'))*appears0.weight,ts_rank(appears2.words, to_tsquery('default', 'hip&hop&momo'))*appears2.weight"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1568 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1569 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1570 |
('Any X, FTIRANK(X) WHERE X has_text "toto tata"', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1571 |
"""SELECT appears0.uid, ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1572 |
FROM appears AS appears0 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1573 |
WHERE appears0.words @@ to_tsquery('default', 'toto&tata')"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1574 |
|
6493
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1575 |
|
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1576 |
('Any X WHERE NOT A tags X, X has_text "pouet"', |
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1577 |
'''SELECT appears1.uid |
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1578 |
FROM appears AS appears1 |
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1579 |
WHERE NOT (EXISTS(SELECT 1 FROM tags_relation AS rel_tags0 WHERE appears1.uid=rel_tags0.eid_to)) AND appears1.words @@ to_tsquery('default', 'pouet') |
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1580 |
'''), |
019ab5eb37ea
[rql2sql] properly compute has_text relation table scope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
1581 |
|
0 | 1582 |
)): |
1583 |
yield t |
|
1584 |
||
1585 |
||
1586 |
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
|
1587 |
queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')", |
0 | 1588 |
'''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
|
1589 |
WHERE EXISTS(SELECT 1 FROM cw_CWGroup AS _T WHERE _T.cw_name=managers)'''), |
0 | 1590 |
('Any X,Y WHERE NOT X created_by Y, X eid 5, Y eid 6', |
1591 |
'''SELECT 5, 6 |
|
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1592 |
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))'''), |
0 | 1593 |
] |
1594 |
for t in self._parse(queries): |
|
1595 |
yield t |
|
1596 |
||
1597 |
def test_ambigous_exists_no_from_clause(self): |
|
1598 |
self._check('Any COUNT(U) WHERE U eid 1, EXISTS (P owned_by U, P is IN (Note, Affaire))', |
|
1599 |
'''SELECT COUNT(1) |
|
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1600 |
WHERE EXISTS(SELECT 1 FROM cw_Affaire AS _P, owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_from=_P.cw_eid AND rel_owned_by0.eid_to=1 UNION SELECT 1 FROM cw_Note AS _P, owned_by_relation AS rel_owned_by1 WHERE rel_owned_by1.eid_from=_P.cw_eid AND rel_owned_by1.eid_to=1)''') |
0 | 1601 |
|
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1602 |
def test_attr_map_sqlcb(self): |
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
|
1603 |
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
|
1604 |
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
|
1605 |
return 'VERSION_DATA(%s)' % linkedvar._q_sql |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1606 |
self.o.attr_map['Affaire.ref'] = (generate_ref, False) |
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
|
1607 |
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
|
1608 |
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
|
1609 |
'''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
|
1610 |
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
|
1611 |
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
|
1612 |
'''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
|
1613 |
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
|
1614 |
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
|
1615 |
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
|
1616 |
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
|
1617 |
|
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1618 |
def test_attr_map_sourcecb(self): |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1619 |
cb = lambda x,y: None |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1620 |
self.o.attr_map['Affaire.ref'] = (cb, True) |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1621 |
try: |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1622 |
union = self._prepare('Any R WHERE X ref R') |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1623 |
r, nargs, cbs = self.o.generate(union, args={}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1624 |
self.assertMultiLineEqual(r.strip(), 'SELECT _X.cw_ref\nFROM cw_Affaire AS _X') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
1625 |
self.assertEqual(cbs, {0: [cb]}) |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1626 |
finally: |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1627 |
self.o.attr_map.clear() |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5010
diff
changeset
|
1628 |
|
0 | 1629 |
|
5793
1faff41593df
[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5582
diff
changeset
|
1630 |
def test_concat_string(self): |
1faff41593df
[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5582
diff
changeset
|
1631 |
self._check('Any "A"+R WHERE X ref R', |
1faff41593df
[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5582
diff
changeset
|
1632 |
'''SELECT (A || _X.cw_ref) |
1faff41593df
[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5582
diff
changeset
|
1633 |
FROM cw_Affaire AS _X''') |
1faff41593df
[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5582
diff
changeset
|
1634 |
|
5887
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1635 |
def test_or_having_fake_terms(self): |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1636 |
self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL', |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1637 |
'''SELECT _X.cw_eid |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1638 |
FROM cw_CWUser AS _X |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1639 |
WHERE ((CAST(EXTRACT(YEAR from _X.cw_creation_date) AS INTEGER)=2010) OR (_X.cw_creation_date IS NULL))''') |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1640 |
|
6297
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1641 |
def test_not_no_where(self): |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1642 |
# XXX will check if some in_group relation exists, that's it. |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1643 |
# We can't actually know if we want to check if there are some |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1644 |
# X without in_group relation, or some G without it. |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1645 |
self._check('Any 1 WHERE NOT X in_group G, X is CWUser', |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1646 |
'''SELECT 1 |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1647 |
WHERE NOT (EXISTS(SELECT 1 FROM in_group_relation AS rel_in_group0))''') |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1648 |
|
7357
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
1649 |
def test_nonregr_outer_join_multiple(self): |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1650 |
self._check('Any COUNT(P1148),G GROUPBY G ' |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1651 |
'WHERE G owned_by D, D eid 1122, K1148 bookmarked_by P1148, ' |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1652 |
'K1148 eid 1148, P1148? in_group G', |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1653 |
'''SELECT COUNT(rel_bookmarked_by1.eid_to), _G.cw_eid |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1654 |
FROM owned_by_relation AS rel_owned_by0, cw_CWGroup AS _G LEFT OUTER JOIN in_group_relation AS rel_in_group2 ON (rel_in_group2.eid_to=_G.cw_eid) LEFT OUTER JOIN bookmarked_by_relation AS rel_bookmarked_by1 ON (rel_in_group2.eid_from=rel_bookmarked_by1.eid_to) |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1655 |
WHERE rel_owned_by0.eid_from=_G.cw_eid AND rel_owned_by0.eid_to=1122 AND rel_bookmarked_by1.eid_from=1148 |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1656 |
GROUP BY _G.cw_eid''' |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1657 |
) |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1658 |
|
7357
5ad3154a8810
[rql2sql] fix bug avoiding outer join relation to be used as a variable principal. Closes #1659395
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7252
diff
changeset
|
1659 |
def test_nonregr_outer_join_multiple2(self): |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1660 |
self._check('Any COUNT(P1148),G GROUPBY G ' |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1661 |
'WHERE G owned_by D, D eid 1122, K1148 bookmarked_by P1148?, ' |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1662 |
'K1148 eid 1148, P1148? in_group G', |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1663 |
'''SELECT COUNT(rel_bookmarked_by1.eid_to), _G.cw_eid |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1664 |
FROM owned_by_relation AS rel_owned_by0, cw_CWGroup AS _G LEFT OUTER JOIN in_group_relation AS rel_in_group2 ON (rel_in_group2.eid_to=_G.cw_eid) LEFT OUTER JOIN bookmarked_by_relation AS rel_bookmarked_by1 ON (rel_bookmarked_by1.eid_from=1148 AND rel_in_group2.eid_from=rel_bookmarked_by1.eid_to) |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1665 |
WHERE rel_owned_by0.eid_from=_G.cw_eid AND rel_owned_by0.eid_to=1122 |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1666 |
GROUP BY _G.cw_eid''') |
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1667 |
|
7579
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1668 |
def test_groupby_orderby_insertion_dont_modify_intention(self): |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1669 |
self._check('Any YEAR(XECT)*100+MONTH(XECT), COUNT(X),SUM(XCE),AVG(XSCT-XECT) ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1670 |
'GROUPBY YEAR(XECT),MONTH(XECT) ORDERBY 1 ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1671 |
'WHERE X creation_date XSCT, X modification_date XECT, ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1672 |
'X ordernum XCE, X is CWAttribute', |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1673 |
'''SELECT ((CAST(EXTRACT(YEAR from _X.cw_modification_date) AS INTEGER) * 100) + CAST(EXTRACT(MONTH from _X.cw_modification_date) AS INTEGER)), COUNT(_X.cw_eid), SUM(_X.cw_ordernum), AVG((_X.cw_creation_date - _X.cw_modification_date)) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1674 |
FROM cw_CWAttribute AS _X |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1675 |
GROUP BY CAST(EXTRACT(YEAR from _X.cw_modification_date) AS INTEGER),CAST(EXTRACT(MONTH from _X.cw_modification_date) AS INTEGER) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1676 |
ORDER BY 1'''), |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1677 |
|
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1678 |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1679 |
class SqlServer2005SQLGeneratorTC(PostgresSQLGeneratorTC): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1680 |
backend = 'sqlserver2005' |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1681 |
def _norm_sql(self, sql): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1682 |
return sql.strip().replace(' SUBSTR', ' SUBSTRING').replace(' || ', ' + ').replace(' ILIKE ', ' LIKE ') |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1683 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1684 |
def test_has_text(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1685 |
for t in self._parse(HAS_TEXT_LG_INDEXER): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1686 |
yield t |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1687 |
|
7257
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1688 |
def test_regexp(self): |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1689 |
self.skipTest('regexp-based pattern matching not implemented in sqlserver') |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1690 |
|
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1691 |
def test_or_having_fake_terms(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1692 |
self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1693 |
'''SELECT _X.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1694 |
FROM cw_CWUser AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1695 |
WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''') |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1696 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1697 |
def test_date_extraction(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1698 |
self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1699 |
'''SELECT MONTH(_P.cw_creation_date) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1700 |
FROM cw_Personne AS _P''') |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1701 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1702 |
def test_symmetric(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1703 |
for t in self._parse(SYMMETRIC): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1704 |
yield t |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1705 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1706 |
def test_basic_parse(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1707 |
for t in self._parse(BASIC):# + BASIC_WITH_LIMIT): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1708 |
yield t |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1709 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1710 |
def test_advanced_parse(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1711 |
for t in self._parse(ADVANCED):# + ADVANCED_WITH_LIMIT_OR_ORDERBY): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1712 |
yield t |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1713 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1714 |
def test_limit_offset(self): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1715 |
WITH_LIMIT = [ |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1716 |
("Personne P LIMIT 20 OFFSET 10", |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1717 |
'''WITH orderedrows AS ( |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1718 |
SELECT |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1719 |
_L01 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1720 |
, ROW_NUMBER() OVER (ORDER BY _L01) AS __RowNumber |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1721 |
FROM ( |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1722 |
SELECT _P.cw_eid AS _L01 FROM cw_Personne AS _P |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1723 |
) AS _SQ1 ) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1724 |
SELECT |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1725 |
_L01 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1726 |
FROM orderedrows WHERE |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1727 |
__RowNumber <= 30 AND __RowNumber > 10 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1728 |
'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1729 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1730 |
('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"))', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1731 |
'''WITH orderedrows AS ( |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1732 |
SELECT |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1733 |
_L01, _L02 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1734 |
, ROW_NUMBER() OVER (ORDER BY _L01 DESC) AS __RowNumber |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1735 |
FROM ( |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1736 |
SELECT COUNT(rel_concerne0.eid_from) AS _L01, _C.cw_nom AS _L02 FROM concerne_relation AS rel_concerne0, cw_Societe AS _C |
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
1737 |
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 cw_Card AS _N, documented_by_relation AS rel_documented_by2 WHERE rel_concerne0.eid_from=rel_documented_by2.eid_from AND rel_documented_by2.eid_to=_N.cw_eid AND _N.cw_title=published))) |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1738 |
GROUP BY _C.cw_nom |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1739 |
) AS _SQ1 ) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1740 |
SELECT |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1741 |
_L01, _L02 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1742 |
FROM orderedrows WHERE |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1743 |
__RowNumber <= 10 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1744 |
'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1745 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1746 |
('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;', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1747 |
'''SELECT T1.C0,T1.C1 FROM (SELECT DISTINCT (MAX(_X.cw_eid) + MIN(LENGTH(_X.cw_data))) AS C0, _X.cw_data_name AS C1, _X.cw_data_format AS C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1748 |
FROM cw_File AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1749 |
GROUP BY _X.cw_data_name,_X.cw_data_format) AS T1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1750 |
ORDER BY T1.C1,T1.C2 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1751 |
'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1752 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1753 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1754 |
('DISTINCT Any X ORDERBY Y WHERE B bookmarked_by X, X login Y', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1755 |
'''SELECT T1.C0 FROM (SELECT DISTINCT _X.cw_eid AS C0, _X.cw_login AS C1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1756 |
FROM bookmarked_by_relation AS rel_bookmarked_by0, cw_CWUser AS _X |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1757 |
WHERE rel_bookmarked_by0.eid_to=_X.cw_eid) AS T1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1758 |
ORDER BY T1.C1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1759 |
'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1760 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1761 |
('DISTINCT Any X ORDERBY SN WHERE X in_state S, S name SN', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1762 |
'''SELECT T1.C0 FROM (SELECT DISTINCT _X.cw_eid AS C0, _S.cw_name AS C1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1763 |
FROM cw_Affaire AS _X, cw_State AS _S |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1764 |
WHERE _X.cw_in_state=_S.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1765 |
UNION |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1766 |
SELECT DISTINCT _X.cw_eid AS C0, _S.cw_name AS C1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1767 |
FROM cw_CWUser AS _X, cw_State AS _S |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1768 |
WHERE _X.cw_in_state=_S.cw_eid |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1769 |
UNION |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1770 |
SELECT DISTINCT _X.cw_eid AS C0, _S.cw_name AS C1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1771 |
FROM cw_Note AS _X, cw_State AS _S |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1772 |
WHERE _X.cw_in_state=_S.cw_eid) AS T1 |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1773 |
ORDER BY T1.C1'''), |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1774 |
|
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1775 |
('Any O,AA,AB,AC ORDERBY AC DESC ' |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1776 |
'WHERE NOT S use_email O, S eid 1, O is EmailAddress, O address AA, O alias AB, O modification_date AC, ' |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1777 |
'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', |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1778 |
''' |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1779 |
SELECT _O.cw_eid, _O.cw_address, _O.cw_alias, _O.cw_modification_date |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1780 |
FROM cw_EmailAddress AS _O |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1781 |
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)) |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1782 |
ORDER BY 4 DESC'''), |
7596
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1783 |
|
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1784 |
("Any P ORDERBY N LIMIT 1 WHERE P is Personne, P travaille S, S eid %(eid)s, P nom N, P nom %(text)s", |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1785 |
'''WITH orderedrows AS ( |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1786 |
SELECT |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1787 |
_L01 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1788 |
, ROW_NUMBER() OVER (ORDER BY _L01) AS __RowNumber |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1789 |
FROM ( |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1790 |
SELECT _P.cw_eid AS _L01 FROM cw_Personne AS _P, travaille_relation AS rel_travaille0 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1791 |
WHERE rel_travaille0.eid_from=_P.cw_eid AND rel_travaille0.eid_to=12345 AND _P.cw_nom=hip hop momo |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1792 |
) AS _SQ1 ) |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1793 |
SELECT |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1794 |
_L01 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1795 |
FROM orderedrows WHERE |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1796 |
__RowNumber <= 1'''), |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1797 |
|
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1798 |
("Any P ORDERBY N LIMIT 1 WHERE P is Personne, P nom N", |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1799 |
'''WITH orderedrows AS ( |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1800 |
SELECT |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1801 |
_L01 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1802 |
, ROW_NUMBER() OVER (ORDER BY _L01) AS __RowNumber |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1803 |
FROM ( |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1804 |
SELECT _P.cw_eid AS _L01 FROM cw_Personne AS _P |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1805 |
) AS _SQ1 ) |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1806 |
SELECT |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1807 |
_L01 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1808 |
FROM orderedrows WHERE |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1809 |
__RowNumber <= 1 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1810 |
'''), |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1811 |
|
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1812 |
("Any PN, N, P ORDERBY N LIMIT 1 WHERE P is Personne, P nom N, P prenom PN", |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1813 |
'''WITH orderedrows AS ( |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1814 |
SELECT |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1815 |
_L01, _L02, _L03 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1816 |
, ROW_NUMBER() OVER (ORDER BY _L02) AS __RowNumber |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1817 |
FROM ( |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1818 |
SELECT _P.cw_prenom AS _L01, _P.cw_nom AS _L02, _P.cw_eid AS _L03 FROM cw_Personne AS _P |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1819 |
) AS _SQ1 ) |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1820 |
SELECT |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1821 |
_L01, _L02, _L03 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1822 |
FROM orderedrows WHERE |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1823 |
__RowNumber <= 1 |
f3cdf1694c92
new rql2sql unit tests for ORDERBY and LIMIT checks in SQLServer
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7587
diff
changeset
|
1824 |
'''), |
7108
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1825 |
] |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1826 |
for t in self._parse(WITH_LIMIT):# + ADVANCED_WITH_LIMIT_OR_ORDERBY): |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1827 |
yield t |
bcdf22734059
Abstract the support for ORDER BY and LIMIT/OFFSET SQL generation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7043
diff
changeset
|
1828 |
|
7256
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1829 |
def test_cast(self): |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1830 |
self._check("Any CAST(String, P) WHERE P is Personne", |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1831 |
'''SELECT CAST(_P.cw_eid AS nvarchar(max)) |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
1832 |
FROM cw_Personne AS _P''') |
6297
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1833 |
|
7579
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1834 |
def test_groupby_orderby_insertion_dont_modify_intention(self): |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1835 |
self._check('Any YEAR(XECT)*100+MONTH(XECT), COUNT(X),SUM(XCE),AVG(XSCT-XECT) ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1836 |
'GROUPBY YEAR(XECT),MONTH(XECT) ORDERBY 1 ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1837 |
'WHERE X creation_date XSCT, X modification_date XECT, ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1838 |
'X ordernum XCE, X is CWAttribute', |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1839 |
'''SELECT ((YEAR(_X.cw_modification_date) * 100) + MONTH(_X.cw_modification_date)), COUNT(_X.cw_eid), SUM(_X.cw_ordernum), AVG((_X.cw_creation_date - _X.cw_modification_date)) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1840 |
FROM cw_CWAttribute AS _X |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1841 |
GROUP BY YEAR(_X.cw_modification_date),MONTH(_X.cw_modification_date) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1842 |
ORDER BY 1'''), |
6297
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
1843 |
|
5793
1faff41593df
[rql2sql] use new dbhelper.sql_concat_string function to deal with sql string concatenation. This together with lgdb 1.0.4 fixes #1055133: SQL Server support : string concatenation issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5582
diff
changeset
|
1844 |
|
0 | 1845 |
class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC): |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1846 |
backend = 'sqlite' |
0 | 1847 |
|
1848 |
def _norm_sql(self, sql): |
|
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1849 |
return sql.strip().replace(' ILIKE ', ' LIKE ') |
0 | 1850 |
|
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
|
1851 |
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
|
1852 |
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
|
1853 |
'''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
|
1854 |
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
|
1855 |
|
7257
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1856 |
def test_regexp(self): |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1857 |
self._check("Any X WHERE X login REGEXP '[0-9].*'", |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1858 |
'''SELECT _X.cw_eid |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1859 |
FROM cw_CWUser AS _X |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1860 |
WHERE _X.cw_login REGEXP [0-9].* |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1861 |
''') |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1862 |
|
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
1863 |
|
0 | 1864 |
def test_union(self): |
1865 |
for t in self._parse(( |
|
1866 |
('(Any N ORDERBY 1 WHERE X name N, X is State)' |
|
1867 |
' UNION ' |
|
1868 |
'(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
|
1869 |
'''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
|
1870 |
FROM cw_State AS _X |
0 | 1871 |
ORDER BY 1 |
1872 |
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
|
1873 |
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
|
1874 |
FROM cw_Transition AS _XX |
0 | 1875 |
ORDER BY 1'''), |
1876 |
)): |
|
1877 |
yield t |
|
1787 | 1878 |
|
0 | 1879 |
|
1880 |
def test_subquery(self): |
|
1881 |
# NOTE: no paren around UNION with sqlitebackend |
|
1882 |
for t in self._parse(( |
|
1883 |
||
1884 |
('Any N ORDERBY 1 WITH N BEING ' |
|
1885 |
'((Any N WHERE X name N, X is State)' |
|
1886 |
' UNION ' |
|
1887 |
'(Any NN WHERE XX name NN, XX is Transition))', |
|
1888 |
'''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
|
1889 |
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
|
1890 |
FROM cw_State AS _X |
0 | 1891 |
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
|
1892 |
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
|
1893 |
FROM cw_Transition AS _XX) AS _T0 |
0 | 1894 |
ORDER BY 1'''), |
1787 | 1895 |
|
0 | 1896 |
('Any N,NX ORDERBY NX WITH N,NX BEING ' |
1897 |
'((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
|
1898 |
' UNION ' |
|
1899 |
'(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))', |
|
1900 |
'''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
|
1901 |
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
|
1902 |
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
|
1903 |
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
|
1904 |
HAVING COUNT(_X.cw_eid)>1 |
0 | 1905 |
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
|
1906 |
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
|
1907 |
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
|
1908 |
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
|
1909 |
HAVING COUNT(_X.cw_eid)>1) AS _T0 |
1787 | 1910 |
ORDER BY 2'''), |
0 | 1911 |
|
1912 |
('Any N,COUNT(X) GROUPBY N HAVING COUNT(X)>1 ' |
|
1913 |
'WITH X, N BEING ((Any X, N WHERE X name N, X is State) UNION ' |
|
1914 |
' (Any X, N WHERE X name N, X is Transition))', |
|
1915 |
'''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
|
1916 |
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
|
1917 |
FROM cw_State AS _X |
0 | 1918 |
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
|
1919 |
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
|
1920 |
FROM cw_Transition AS _X) AS _T0 |
0 | 1921 |
GROUP BY _T0.C1 |
1922 |
HAVING COUNT(_T0.C0)>1'''), |
|
1923 |
)): |
|
1924 |
yield t |
|
1787 | 1925 |
|
0 | 1926 |
def test_has_text(self): |
1927 |
for t in self._parse(( |
|
1928 |
('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
|
1929 |
"""SELECT DISTINCT appears0.uid |
0 | 1930 |
FROM appears AS appears0 |
1931 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
|
1787 | 1932 |
|
0 | 1933 |
('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
|
1934 |
"""SELECT DISTINCT appears0.uid |
0 | 1935 |
FROM appears AS appears0 |
1936 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('hip', 'hop', 'momo'))"""), |
|
1787 | 1937 |
|
0 | 1938 |
('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
|
1939 |
"""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
|
1940 |
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
|
1941 |
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 | 1942 |
|
3587 | 1943 |
('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
|
1944 |
"""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
|
1945 |
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
|
1946 |
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
|
1947 |
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
|
1948 |
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
|
1949 |
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
|
1950 |
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
|
1951 |
"""), |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1952 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1953 |
('Any X ORDERBY FTIRANK(X) WHERE X has_text "toto tata"', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1954 |
"""SELECT DISTINCT appears0.uid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1955 |
FROM appears AS appears0 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1956 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1957 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1958 |
('Any X ORDERBY FTIRANK(X) WHERE X has_text "toto tata", X name "tutu", X is IN (Basket,Folder)', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1959 |
"""SELECT DISTINCT _X.cw_eid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1960 |
FROM appears AS appears0, cw_Basket AS _X |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1961 |
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 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1962 |
UNION |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1963 |
SELECT DISTINCT _X.cw_eid |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1964 |
FROM appears AS appears0, cw_Folder AS _X |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1965 |
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 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1966 |
"""), |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1967 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1968 |
('Any X, FTIRANK(X) WHERE X has_text "toto tata"', |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1969 |
"""SELECT DISTINCT appears0.uid, 1.0 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1970 |
FROM appears AS appears0 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1971 |
WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""), |
0 | 1972 |
)): |
1973 |
yield t |
|
1974 |
||
1975 |
||
5887
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1976 |
def test_or_having_fake_terms(self): |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1977 |
self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL', |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1978 |
'''SELECT _X.cw_eid |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1979 |
FROM cw_CWUser AS _X |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1980 |
WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''') |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1981 |
|
7579
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1982 |
def test_groupby_orderby_insertion_dont_modify_intention(self): |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1983 |
self._check('Any YEAR(XECT)*100+MONTH(XECT), COUNT(X),SUM(XCE),AVG(XSCT-XECT) ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1984 |
'GROUPBY YEAR(XECT),MONTH(XECT) ORDERBY 1 ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1985 |
'WHERE X creation_date XSCT, X modification_date XECT, ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1986 |
'X ordernum XCE, X is CWAttribute', |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1987 |
'''SELECT ((YEAR(_X.cw_modification_date) * 100) + MONTH(_X.cw_modification_date)), COUNT(_X.cw_eid), SUM(_X.cw_ordernum), AVG((_X.cw_creation_date - _X.cw_modification_date)) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1988 |
FROM cw_CWAttribute AS _X |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1989 |
GROUP BY YEAR(_X.cw_modification_date),MONTH(_X.cw_modification_date) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1990 |
ORDER BY 1'''), |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
1991 |
|
5887
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
1992 |
|
0 | 1993 |
|
1994 |
class MySQLGenerator(PostgresSQLGeneratorTC): |
|
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5590
diff
changeset
|
1995 |
backend = 'mysql' |
0 | 1996 |
|
1997 |
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
|
1998 |
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
|
1999 |
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
|
2000 |
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
|
2001 |
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
|
2002 |
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
|
2003 |
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
|
2004 |
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
|
2005 |
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
|
2006 |
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
|
2007 |
return '\n'.join(newsql) |
0 | 2008 |
|
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
|
2009 |
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
|
2010 |
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
|
2011 |
'''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
|
2012 |
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
|
2013 |
|
7256
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
2014 |
def test_cast(self): |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
2015 |
self._check("Any CAST(String, P) WHERE P is Personne", |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
2016 |
'''SELECT CAST(_P.cw_eid AS mediumtext) |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
2017 |
FROM cw_Personne AS _P''') |
ccd44caeb936
[rql] support CAST() Function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7252
diff
changeset
|
2018 |
|
7257
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2019 |
def test_regexp(self): |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2020 |
self._check("Any X WHERE X login REGEXP '[0-9].*'", |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2021 |
'''SELECT _X.cw_eid |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2022 |
FROM cw_CWUser AS _X |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2023 |
WHERE _X.cw_login REGEXP [0-9].* |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2024 |
''') |
beea955b45e2
[rql] basic support for regexp-based pattern matching
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7256
diff
changeset
|
2025 |
|
0 | 2026 |
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
|
2027 |
queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')", |
0 | 2028 |
'''SELECT 1 |
2029 |
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
|
2030 |
WHERE EXISTS(SELECT 1 FROM cw_CWGroup AS _T WHERE _T.cw_name=managers)'''), |
0 | 2031 |
('Any X,Y WHERE NOT X created_by Y, X eid 5, Y eid 6', |
2032 |
'''SELECT 5, 6 |
|
2033 |
FROM (SELECT 1) AS _T |
|
5582
3e133b29a1a4
[rql2sql] follow rql 0.26.1 changes: NOT nodes normalization, allowing simplification of sql generation, and fix #XXX
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
2034 |
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))'''), |
0 | 2035 |
] |
2036 |
for t in self._parse(queries): |
|
2037 |
yield t |
|
2038 |
||
2039 |
||
2040 |
def test_has_text(self): |
|
2041 |
queries = [ |
|
2042 |
('Any X WHERE X has_text "toto tata"', |
|
2043 |
"""SELECT appears0.uid |
|
2044 |
FROM appears AS appears0 |
|
2045 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE)"""), |
|
2046 |
('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
|
2047 |
"""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
|
2048 |
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
|
2049 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=_X.eid AND _X.type='Personne'"""), |
0 | 2050 |
('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
|
2051 |
"""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
|
2052 |
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
|
2053 |
WHERE MATCH (appears0.words) AGAINST ('hip hop momo' IN BOOLEAN MODE) AND appears0.uid=_X.eid AND _X.type='Personne'"""), |
3587 | 2054 |
('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
|
2055 |
"""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
|
2056 |
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
|
2057 |
WHERE MATCH (appears0.words) AGAINST ('toto tata' IN BOOLEAN MODE) AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu |
0 | 2058 |
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
|
2059 |
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
|
2060 |
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
|
2061 |
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
|
2062 |
""") |
0 | 2063 |
] |
2064 |
for t in self._parse(queries): |
|
2065 |
yield t |
|
1787 | 2066 |
|
0 | 2067 |
|
2068 |
def test_ambigous_exists_no_from_clause(self): |
|
2069 |
self._check('Any COUNT(U) WHERE U eid 1, EXISTS (P owned_by U, P is IN (Note, Affaire))', |
|
2070 |
'''SELECT COUNT(1) |
|
2071 |
FROM (SELECT 1) AS _T |
|
7193
7eaef037ea9d
[sql generation] fix missing join with outer joins w/ rhs invariant variable...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7142
diff
changeset
|
2072 |
WHERE EXISTS(SELECT 1 FROM cw_Affaire AS _P, owned_by_relation AS rel_owned_by0 WHERE rel_owned_by0.eid_from=_P.cw_eid AND rel_owned_by0.eid_to=1 UNION SELECT 1 FROM cw_Note AS _P, owned_by_relation AS rel_owned_by1 WHERE rel_owned_by1.eid_from=_P.cw_eid AND rel_owned_by1.eid_to=1)''') |
0 | 2073 |
|
4289
890dc89516f1
fix bad indent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4286
diff
changeset
|
2074 |
def test_groupby_multiple_outerjoins(self): |
890dc89516f1
fix bad indent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4286
diff
changeset
|
2075 |
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
|
2076 |
'''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
|
2077 |
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
|
2078 |
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
|
2079 |
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
|
2080 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
2081 |
def test_substring(self): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
2082 |
self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne", |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
2083 |
'''SELECT SUBSTRING(_P.cw_nom, 1, 1) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5016
diff
changeset
|
2084 |
FROM cw_Personne AS _P''') |
1787 | 2085 |
|
5887
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2086 |
|
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2087 |
def test_or_having_fake_terms(self): |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2088 |
self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL', |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2089 |
'''SELECT _X.cw_eid |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2090 |
FROM cw_CWUser AS _X |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2091 |
WHERE ((EXTRACT(YEAR from _X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''') |
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2092 |
|
3f55f0f10a22
[rql2sql] test and fix crash when OR in HAVING where both expresion are 'fake' having terms (eg not using aggregat function)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
2093 |
|
6297
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2094 |
def test_not_no_where(self): |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2095 |
self._check('Any 1 WHERE NOT X in_group G, X is CWUser', |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2096 |
'''SELECT 1 |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2097 |
FROM (SELECT 1) AS _T |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2098 |
WHERE NOT (EXISTS(SELECT 1 FROM in_group_relation AS rel_in_group0))''') |
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2099 |
|
7579
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2100 |
def test_groupby_orderby_insertion_dont_modify_intention(self): |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2101 |
self._check('Any YEAR(XECT)*100+MONTH(XECT), COUNT(X),SUM(XCE),AVG(XSCT-XECT) ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2102 |
'GROUPBY YEAR(XECT),MONTH(XECT) ORDERBY 1 ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2103 |
'WHERE X creation_date XSCT, X modification_date XECT, ' |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2104 |
'X ordernum XCE, X is CWAttribute', |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2105 |
'''SELECT ((EXTRACT(YEAR from _X.cw_modification_date) * 100) + EXTRACT(MONTH from _X.cw_modification_date)), COUNT(_X.cw_eid), SUM(_X.cw_ordernum), AVG((_X.cw_creation_date - _X.cw_modification_date)) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2106 |
FROM cw_CWAttribute AS _X |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2107 |
GROUP BY EXTRACT(YEAR from _X.cw_modification_date),EXTRACT(MONTH from _X.cw_modification_date) |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2108 |
ORDER BY 1'''), |
5a610b34d2d2
[rql2sql] more cases fixed where something is wrongly added to GROUPBY, causing unexpected results for the query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7472
diff
changeset
|
2109 |
|
6297
23c1e50ff97b
[rql] fix bug with query like 'Any 1 WHERE NOT X in_group G': tables should be kept in EXISTS() even when there are no restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6194
diff
changeset
|
2110 |
|
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
|
2111 |
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
|
2112 |
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
|
2113 |
rqlst = mock_object(defined_vars={}) |
5004
4cc020ee70e2
le patch rql26 a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4998
diff
changeset
|
2114 |
rqlst.defined_vars['A'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=True) |
4cc020ee70e2
le patch rql26 a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4998
diff
changeset
|
2115 |
rqlst.defined_vars['B'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=False) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
2116 |
self.assertEqual(remove_unused_solutions(rqlst, [{'A': 'RugbyGroup', 'B': 'RugbyTeam'}, |
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
|
2117 |
{'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
|
2118 |
([{'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
|
2119 |
{'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
|
2120 |
{}, 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
|
2121 |
) |
1787 | 2122 |
|
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
|
2123 |
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
|
2124 |
rqlst = mock_object(defined_vars={}) |
5004
4cc020ee70e2
le patch rql26 a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4998
diff
changeset
|
2125 |
rqlst.defined_vars['A'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=True) |
4cc020ee70e2
le patch rql26 a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4998
diff
changeset
|
2126 |
rqlst.defined_vars['B'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=False) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6297
diff
changeset
|
2127 |
self.assertEqual(remove_unused_solutions(rqlst, [{'A': 'RugbyGroup', 'B': 'RugbyTeam'}, |
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
|
2128 |
{'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
|
2129 |
([{'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
|
2130 |
) |
0 | 2131 |
|
5575
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
2132 |
|
0 | 2133 |
if __name__ == '__main__': |
2134 |
unittest_main() |