author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 24 Sep 2010 18:20:59 +0200 | |
branch | stable |
changeset 6340 | 470d8e828fda |
parent 6337 | 6686ca1826a9 |
child 6640 | 4c4616c02f69 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4908
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
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:
4908
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
18 |
|
0 | 19 |
from logilab.common.testlib import unittest_main, TestCase |
20 |
from logilab.common.testlib import mock_object |
|
4908
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
21 |
from yams import BadSchemaDefinition |
0 | 22 |
from rql import parse, nodes, RQLHelper |
23 |
||
24 |
from cubicweb import Unauthorized |
|
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:
5424
diff
changeset
|
25 |
from cubicweb.schema import RRQLExpression, ERQLExpression |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
26 |
from cubicweb.rqlrewrite import RQLRewriter |
0 | 27 |
from cubicweb.devtools import repotest, TestServerConfiguration |
28 |
||
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
29 |
config = TestServerConfiguration('data/rewrite') |
0 | 30 |
config.bootstrap_cubes() |
31 |
schema = config.load_schema() |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3826
diff
changeset
|
32 |
from yams.buildobjs import RelationDefinition |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3826
diff
changeset
|
33 |
schema.add_relation_def(RelationDefinition(subject='Card', name='in_state', object='State', cardinality='1*')) |
1787 | 34 |
|
0 | 35 |
rqlhelper = RQLHelper(schema, special_relations={'eid': 'uid', |
36 |
'has_text': 'fti'}) |
|
37 |
||
38 |
def setup_module(*args): |
|
39 |
repotest.do_monkey_patch() |
|
40 |
||
41 |
def teardown_module(*args): |
|
42 |
repotest.undo_monkey_patch() |
|
1787 | 43 |
|
0 | 44 |
def eid_func_map(eid): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
45 |
return {1: 'CWUser', |
0 | 46 |
2: 'Card'}[eid] |
47 |
||
3826
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
48 |
def rewrite(rqlst, snippets_map, kwargs, existingvars=None): |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
49 |
class FakeVReg: |
0 | 50 |
schema = schema |
51 |
@staticmethod |
|
52 |
def solutions(sqlcursor, mainrqlst, kwargs): |
|
53 |
rqlhelper.compute_solutions(rqlst, {'eid': eid_func_map}, kwargs=kwargs) |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
54 |
class rqlhelper: |
0 | 55 |
@staticmethod |
56 |
def annotate(rqlst): |
|
57 |
rqlhelper.annotate(rqlst) |
|
58 |
@staticmethod |
|
59 |
def simplify(mainrqlst, needcopy=False): |
|
60 |
rqlhelper.simplify(rqlst, needcopy) |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
61 |
rewriter = RQLRewriter(mock_object(vreg=FakeVReg, user=(mock_object(eid=1)))) |
0 | 62 |
for v, snippets in snippets_map.items(): |
3826
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
63 |
snippets_map[v] = [isinstance(snippet, basestring) |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
64 |
and mock_object(snippet_rqlst=parse('Any X WHERE '+snippet).children[0], |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
65 |
expression='Any X WHERE '+snippet) |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
66 |
or snippet |
0 | 67 |
for snippet in snippets] |
68 |
rqlhelper.compute_solutions(rqlst.children[0], {'eid': eid_func_map}, kwargs=kwargs) |
|
69 |
solutions = rqlst.children[0].solutions |
|
3826
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
70 |
rewriter.rewrite(rqlst.children[0], snippets_map.items(), solutions, kwargs, |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
71 |
existingvars) |
0 | 72 |
test_vrefs(rqlst.children[0]) |
73 |
return rewriter.rewritten |
|
74 |
||
75 |
def test_vrefs(node): |
|
76 |
vrefmap = {} |
|
77 |
for vref in node.iget_nodes(nodes.VariableRef): |
|
78 |
vrefmap.setdefault(vref.name, set()).add(vref) |
|
79 |
for var in node.defined_vars.itervalues(): |
|
80 |
assert not (var.stinfo['references'] ^ vrefmap[var.name]) |
|
81 |
assert (var.stinfo['references']) |
|
82 |
||
83 |
class RQLRewriteTC(TestCase): |
|
84 |
"""a faire: |
|
85 |
||
86 |
* optimisation: detecter les relations utilisees dans les rqlexpressions qui |
|
87 |
sont presentes dans la requete de depart pour les reutiliser si possible |
|
1787 | 88 |
|
0 | 89 |
* "has_<ACTION>_permission" ? |
90 |
""" |
|
1787 | 91 |
|
0 | 92 |
def test_base_var(self): |
93 |
card_constraint = ('X in_state S, U in_group G, P require_state S,' |
|
94 |
'P name "read", P require_group G') |
|
95 |
rqlst = parse('Card C') |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
96 |
rewrite(rqlst, {('C', 'X'): (card_constraint,)}, {}) |
0 | 97 |
self.failUnlessEqual(rqlst.as_string(), |
98 |
u"Any C WHERE C is Card, B eid %(D)s, " |
|
99 |
"EXISTS(C in_state A, B in_group E, F require_state A, " |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
100 |
"F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission)") |
1787 | 101 |
|
0 | 102 |
def test_multiple_var(self): |
103 |
card_constraint = ('X in_state S, U in_group G, P require_state S,' |
|
104 |
'P name "read", P require_group G') |
|
105 |
affaire_constraints = ('X ref LIKE "PUBLIC%"', 'U in_group G, G name "public"') |
|
106 |
kwargs = {'u':2} |
|
107 |
rqlst = parse('Any S WHERE S documented_by C, C eid %(u)s') |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
108 |
rewrite(rqlst, {('C', 'X'): (card_constraint,), ('S', 'X'): affaire_constraints}, |
0 | 109 |
kwargs) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6337
diff
changeset
|
110 |
self.assertMultiLineEqual(rqlst.as_string(), |
0 | 111 |
"Any S WHERE S documented_by C, C eid %(u)s, B eid %(D)s, " |
112 |
"EXISTS(C in_state A, B in_group E, F require_state A, " |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
113 |
"F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission), " |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
114 |
"(EXISTS(S ref LIKE 'PUBLIC%')) OR (EXISTS(B in_group G, G name 'public', G is CWGroup)), " |
0 | 115 |
"S is Affaire") |
116 |
self.failUnless('D' in kwargs) |
|
1787 | 117 |
|
0 | 118 |
def test_or(self): |
119 |
constraint = '(X identity U) OR (X in_state ST, CL identity U, CL in_state ST, ST name "subscribed")' |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
120 |
rqlst = parse('Any S WHERE S owned_by C, C eid %(u)s, S is in (CWUser, CWGroup)') |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
121 |
rewrite(rqlst, {('C', 'X'): (constraint,)}, {'u':1}) |
0 | 122 |
self.failUnlessEqual(rqlst.as_string(), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
123 |
"Any S WHERE S owned_by C, C eid %(u)s, S is IN(CWUser, CWGroup), A eid %(B)s, " |
0 | 124 |
"EXISTS((C identity A) OR (C in_state D, E identity A, " |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
125 |
"E in_state D, D name 'subscribed'), D is State, E is CWUser)") |
0 | 126 |
|
127 |
def test_simplified_rqlst(self): |
|
128 |
card_constraint = ('X in_state S, U in_group G, P require_state S,' |
|
129 |
'P name "read", P require_group G') |
|
130 |
rqlst = parse('Any 2') # this is the simplified rql st for Any X WHERE X eid 12 |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
131 |
rewrite(rqlst, {('2', 'X'): (card_constraint,)}, {}) |
0 | 132 |
self.failUnlessEqual(rqlst.as_string(), |
133 |
u"Any 2 WHERE B eid %(C)s, " |
|
134 |
"EXISTS(2 in_state A, B in_group D, E require_state A, " |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
135 |
"E name 'read', E require_group D, A is State, D is CWGroup, E is CWPermission)") |
0 | 136 |
|
4907
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
137 |
def test_optional_var_base(self): |
0 | 138 |
card_constraint = ('X in_state S, U in_group G, P require_state S,' |
139 |
'P name "read", P require_group G') |
|
140 |
rqlst = parse('Any A,C WHERE A documented_by C?') |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
141 |
rewrite(rqlst, {('C', 'X'): (card_constraint,)}, {}) |
0 | 142 |
self.failUnlessEqual(rqlst.as_string(), |
143 |
"Any A,C WHERE A documented_by C?, A is Affaire " |
|
144 |
"WITH C BEING " |
|
4907
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
145 |
"(Any C WHERE EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
146 |
"G require_group F), D eid %(A)s, C is Card)") |
0 | 147 |
rqlst = parse('Any A,C,T WHERE A documented_by C?, C title T') |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
148 |
rewrite(rqlst, {('C', 'X'): (card_constraint,)}, {}) |
0 | 149 |
self.failUnlessEqual(rqlst.as_string(), |
150 |
"Any A,C,T WHERE A documented_by C?, A is Affaire " |
|
151 |
"WITH C,T BEING " |
|
4907
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
152 |
"(Any C,T WHERE C title T, EXISTS(C in_state B, D in_group F, " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
153 |
"G require_state B, G name 'read', G require_group F), " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
154 |
"D eid %(A)s, C is Card)") |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
155 |
|
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
156 |
def test_optional_var_inlined(self): |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
157 |
c1 = ('X require_permission P') |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
158 |
c2 = ('X inlined_card O, O require_permission P') |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
159 |
rqlst = parse('Any C,A,R WHERE A? inlined_card C, A ref R') |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
160 |
rewrite(rqlst, {('C', 'X'): (c1,), |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
161 |
('A', 'X'): (c2,), |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
162 |
}, {}) |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
163 |
# XXX suboptimal |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
164 |
self.failUnlessEqual(rqlst.as_string(), |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
165 |
"Any C,A,R WITH A,R,C BEING " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
166 |
"(Any A,R,C WHERE A ref R, A? inlined_card C, " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
167 |
"(A is NULL) OR (EXISTS(A inlined_card B, B require_permission D, " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
168 |
"B is Card, D is CWPermission)), " |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
169 |
"A is Affaire, C is Card, EXISTS(C require_permission E, E is CWPermission))") |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
170 |
|
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
171 |
# def test_optional_var_inlined_has_perm(self): |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
172 |
# c1 = ('X require_permission P') |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
173 |
# c2 = ('X inlined_card O, U has_read_permission O') |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
174 |
# rqlst = parse('Any C,A,R WHERE A? inlined_card C, A ref R') |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
175 |
# rewrite(rqlst, {('C', 'X'): (c1,), |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
176 |
# ('A', 'X'): (c2,), |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
177 |
# }, {}) |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
178 |
# self.failUnlessEqual(rqlst.as_string(), |
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
179 |
# "") |
1787 | 180 |
|
4908
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
181 |
def test_optional_var_inlined_imbricated_error(self): |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
182 |
c1 = ('X require_permission P') |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
183 |
c2 = ('X inlined_card O, O require_permission P') |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
184 |
rqlst = parse('Any C,A,R,A2,R2 WHERE A? inlined_card C, A ref R,A2? inlined_card C, A2 ref R2') |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
185 |
self.assertRaises(BadSchemaDefinition, |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
186 |
rewrite, rqlst, {('C', 'X'): (c1,), |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
187 |
('A', 'X'): (c2,), |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
188 |
('A2', 'X'): (c2,), |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
189 |
}, {}) |
b3ad329cbe17
[rql rewrite] until a better solution is found raise BadSchemaDefinition when two inlined relations with security on an optional variable is used, explaining how to bypass it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4907
diff
changeset
|
190 |
|
3443
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
191 |
def test_relation_optimization_1_lhs(self): |
0 | 192 |
# since Card in_state State as monovalued cardinality, the in_state |
193 |
# relation used in the rql expression can be ignored and S replaced by |
|
194 |
# the variable from the incoming query |
|
3443
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
195 |
snippet = ('X in_state S, S name "hop"') |
0 | 196 |
rqlst = parse('Card C WHERE C in_state STATE') |
3443
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
197 |
rewrite(rqlst, {('C', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
198 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
199 |
"Any C WHERE C in_state STATE, C is Card, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
200 |
"EXISTS(STATE name 'hop'), STATE is State") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
201 |
def test_relation_optimization_1_rhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
202 |
snippet = ('TW subworkflow_exit X, TW name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
203 |
rqlst = parse('WorkflowTransition C WHERE C subworkflow_exit EXIT') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
204 |
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
205 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
206 |
"Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
207 |
"EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
208 |
|
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
209 |
def test_relation_optimization_2_lhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
210 |
# optional relation can be shared if also optional in the snippet |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
211 |
snippet = ('X in_state S?, S name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
212 |
rqlst = parse('Card C WHERE C in_state STATE?') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
213 |
rewrite(rqlst, {('C', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
214 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
215 |
"Any C WHERE C in_state STATE?, C is Card, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
216 |
"EXISTS(STATE name 'hop'), STATE is State") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
217 |
def test_relation_optimization_2_rhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
218 |
snippet = ('TW? subworkflow_exit X, TW name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
219 |
rqlst = parse('SubWorkflowExitPoint EXIT WHERE C? subworkflow_exit EXIT') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
220 |
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {}) |
0 | 221 |
self.failUnlessEqual(rqlst.as_string(), |
3443
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
222 |
"Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
223 |
"EXISTS(C name 'hop'), C is WorkflowTransition") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
224 |
|
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
225 |
def test_relation_optimization_3_lhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
226 |
# optional relation in the snippet but not in the orig tree can be shared |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
227 |
snippet = ('X in_state S?, S name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
228 |
rqlst = parse('Card C WHERE C in_state STATE') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
229 |
rewrite(rqlst, {('C', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
230 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
231 |
"Any C WHERE C in_state STATE, C is Card, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
232 |
"EXISTS(STATE name 'hop'), STATE is State") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
233 |
def test_relation_optimization_3_rhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
234 |
snippet = ('TW? subworkflow_exit X, TW name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
235 |
rqlst = parse('WorkflowTransition C WHERE C subworkflow_exit EXIT') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
236 |
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
237 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
238 |
"Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
239 |
"EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
240 |
|
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
241 |
def test_relation_non_optimization_1_lhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
242 |
# but optional relation in the orig tree but not in the snippet can't be shared |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
243 |
snippet = ('X in_state S, S name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
244 |
rqlst = parse('Card C WHERE C in_state STATE?') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
245 |
rewrite(rqlst, {('C', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
246 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
247 |
"Any C WHERE C in_state STATE?, C is Card, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
248 |
"EXISTS(C in_state A, A name 'hop', A is State), STATE is State") |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
249 |
def test_relation_non_optimization_1_rhs(self): |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
250 |
snippet = ('TW subworkflow_exit X, TW name "hop"') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
251 |
rqlst = parse('SubWorkflowExitPoint EXIT WHERE C? subworkflow_exit EXIT') |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
252 |
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {}) |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
253 |
self.failUnlessEqual(rqlst.as_string(), |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
254 |
"Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
255 |
"EXISTS(A subworkflow_exit EXIT, A name 'hop', A is WorkflowTransition), " |
34e451da9b5d
[security] test and fix/refactor optimization of optional varialbe when rewriting rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3240
diff
changeset
|
256 |
"C is WorkflowTransition") |
0 | 257 |
|
258 |
def test_unsupported_constraint_1(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
259 |
# CWUser doesn't have require_permission |
0 | 260 |
trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
261 |
rqlst = parse('Any U,T WHERE U is CWUser, T wf_info_for U') |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
262 |
self.assertRaises(Unauthorized, rewrite, rqlst, {('T', 'X'): (trinfo_constraint,)}, {}) |
1787 | 263 |
|
0 | 264 |
def test_unsupported_constraint_2(self): |
265 |
trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
266 |
rqlst = parse('Any U,T WHERE U is CWUser, T wf_info_for U') |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
267 |
rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X wf_info_for Y, Y in_group G, G name "managers"')}, {}) |
0 | 268 |
self.failUnlessEqual(rqlst.as_string(), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
269 |
u"Any U,T WHERE U is CWUser, T wf_info_for U, " |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
270 |
"EXISTS(U in_group B, B name 'managers', B is CWGroup), T is TrInfo") |
0 | 271 |
|
272 |
def test_unsupported_constraint_3(self): |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6337
diff
changeset
|
273 |
self.skipTest('raise unauthorized for now') |
0 | 274 |
trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"') |
275 |
rqlst = parse('Any T WHERE T wf_info_for X') |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
276 |
rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X in_group G, G name "managers"')}, {}) |
0 | 277 |
self.failUnlessEqual(rqlst.as_string(), |
278 |
u'XXX dunno what should be generated') |
|
1787 | 279 |
|
0 | 280 |
def test_add_ambiguity_exists(self): |
281 |
constraint = ('X concerne Y') |
|
282 |
rqlst = parse('Affaire X') |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
283 |
rewrite(rqlst, {('X', 'X'): (constraint,)}, {}) |
0 | 284 |
self.failUnlessEqual(rqlst.as_string(), |
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
285 |
u"Any X WHERE X is Affaire, ((EXISTS(X concerne A, A is Division)) OR (EXISTS(X concerne C, C is Societe))) OR (EXISTS(X concerne B, B is Note))") |
1787 | 286 |
|
0 | 287 |
def test_add_ambiguity_outerjoin(self): |
288 |
constraint = ('X concerne Y') |
|
289 |
rqlst = parse('Any X,C WHERE X? documented_by C') |
|
3240
8604a15995d1
refactor so that rql rewriter may be used outside the server. Enhance it to be usable for RRQLExpression as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
290 |
rewrite(rqlst, {('X', 'X'): (constraint,)}, {}) |
0 | 291 |
# ambiguity are kept in the sub-query, no need to be resolved using OR |
292 |
self.failUnlessEqual(rqlst.as_string(), |
|
4907
e623afd49356
[rql rewriting] handle case where we've and optional inlined relation in the original query. Also, we should append EXISTS even in subquery to avoid inserting duplicates in results
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
293 |
u"Any X,C WHERE X? documented_by C, C is Card WITH X BEING (Any X WHERE EXISTS(X concerne A), X is Affaire)") |
1787 | 294 |
|
295 |
||
3826
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
296 |
def test_rrqlexpr_nonexistant_subject_1(self): |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
297 |
constraint = RRQLExpression('S owned_by U') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
298 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
299 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
300 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
301 |
u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)") |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
302 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
303 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
304 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
305 |
u"Any C WHERE C is Card") |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
306 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
307 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SOU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
308 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
309 |
u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)") |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
310 |
|
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
311 |
def test_rrqlexpr_nonexistant_subject_2(self): |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
312 |
constraint = RRQLExpression('S owned_by U, O owned_by U, O is Card') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
313 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
314 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
315 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
316 |
'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
317 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
318 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
319 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
320 |
'Any C WHERE C is Card, B eid %(D)s, EXISTS(A owned_by B, A is Card)') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
321 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
322 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SOU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
323 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
324 |
'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A, D owned_by A, D is Card)') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
325 |
|
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
326 |
def test_rrqlexpr_nonexistant_subject_3(self): |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
327 |
constraint = RRQLExpression('U in_group G, G name "users"') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
328 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
329 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
330 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
331 |
u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
332 |
|
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
333 |
def test_rrqlexpr_nonexistant_subject_4(self): |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
334 |
constraint = RRQLExpression('U in_group G, G name "users", S owned_by U') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
335 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
336 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
337 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
338 |
u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", C owned_by A, D is CWGroup)') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
339 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
340 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
341 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
342 |
u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
343 |
|
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
344 |
def test_rrqlexpr_nonexistant_subject_5(self): |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
345 |
constraint = RRQLExpression('S owned_by Z, O owned_by Z, O is Card') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
346 |
rqlst = parse('Card C') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
347 |
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'S') |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
348 |
self.failUnlessEqual(rqlst.as_string(), |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
349 |
u"Any C WHERE C is Card, EXISTS(C owned_by A, A is CWUser)") |
0c0c051863cb
close #511810: bad rql generated when looking for vocabulary for a relation on an entity which doesn't exist (yet)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3443
diff
changeset
|
350 |
|
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:
5424
diff
changeset
|
351 |
def test_rqlexpr_not_relation1(self): |
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:
5424
diff
changeset
|
352 |
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X') |
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:
5424
diff
changeset
|
353 |
rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)') |
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:
5424
diff
changeset
|
354 |
rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X') |
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:
5424
diff
changeset
|
355 |
self.failUnlessEqual(rqlst.as_string(), |
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:
5424
diff
changeset
|
356 |
u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire') |
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:
5424
diff
changeset
|
357 |
|
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:
5424
diff
changeset
|
358 |
def test_rqlexpr_not_relation2(self): |
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:
5424
diff
changeset
|
359 |
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X') |
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:
5424
diff
changeset
|
360 |
rqlst = rqlhelper.parse('Affaire A WHERE NOT A documented_by C', annotate=False) |
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:
5424
diff
changeset
|
361 |
rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X') |
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:
5424
diff
changeset
|
362 |
self.failUnlessEqual(rqlst.as_string(), |
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:
5424
diff
changeset
|
363 |
u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire') |
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:
5424
diff
changeset
|
364 |
|
1787 | 365 |
|
0 | 366 |
if __name__ == '__main__': |
367 |
unittest_main() |