Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RQL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
RQL
Commits
53e9cd50975e
Commit
53e9cd50975e
authored
16 years ago
by
Sylvain Thenault
Browse files
Options
Downloads
Patches
Plain Diff
set variable scope to the outer common parent scope
parent
d38764ab62ef
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nodes.py
+5
-6
5 additions, 6 deletions
nodes.py
utils.py
+19
-0
19 additions, 0 deletions
utils.py
with
24 additions
and
6 deletions
nodes.py
+
5
−
6
View file @
53e9cd50
...
@@ -26,7 +26,8 @@
...
@@ -26,7 +26,8 @@
from
rql
import
CoercionError
from
rql
import
CoercionError
from
rql.base
import
BaseNode
,
Node
,
BinaryNode
,
LeafNode
from
rql.base
import
BaseNode
,
Node
,
BinaryNode
,
LeafNode
from
rql.utils
import
function_description
,
quote
,
uquote
,
build_visitor_stub
from
rql.utils
import
(
function_description
,
quote
,
uquote
,
build_visitor_stub
,
common_parent
)
CONSTANT_TYPES
=
frozenset
((
None
,
'
Date
'
,
'
Datetime
'
,
'
Boolean
'
,
'
Float
'
,
'
Int
'
,
CONSTANT_TYPES
=
frozenset
((
None
,
'
Date
'
,
'
Datetime
'
,
'
Boolean
'
,
'
Float
'
,
'
Int
'
,
'
String
'
,
'
Substitute
'
,
'
etype
'
))
'
String
'
,
'
Substitute
'
,
'
etype
'
))
...
@@ -949,11 +950,8 @@
...
@@ -949,11 +950,8 @@
def
set_scope
(
self
,
scopenode
):
def
set_scope
(
self
,
scopenode
):
if
scopenode
is
self
.
stmt
or
self
.
stinfo
[
'
scope
'
]
is
None
:
if
scopenode
is
self
.
stmt
or
self
.
stinfo
[
'
scope
'
]
is
None
:
self
.
stinfo
[
'
scope
'
]
=
scopenode
self
.
stinfo
[
'
scope
'
]
=
scopenode
elif
self
.
stinfo
[
'
scope
'
]
is
not
self
.
stmt
and
scopenode
is
not
self
.
stinfo
[
'
scope
'
]:
elif
not
(
self
.
stinfo
[
'
scope
'
]
is
self
.
stmt
or
scopenode
is
self
.
stinfo
[
'
scope
'
]):
# XXX get common parent scope if this assertion fail
self
.
stinfo
[
'
scope
'
]
=
common_parent
(
self
.
stinfo
[
'
scope
'
],
scopenode
)
assert
scopenode
.
parent
.
scope
is
self
.
stinfo
[
'
scope
'
].
parent
.
scope
,
\
(
scopenode
.
parent
.
scope
,
self
.
stinfo
[
'
scope
'
].
parent
.
scope
)
self
.
stinfo
[
'
scope
'
]
=
scopenode
.
parent
.
scope
def
get_scope
(
self
):
def
get_scope
(
self
):
return
self
.
stinfo
[
'
scope
'
]
return
self
.
stinfo
[
'
scope
'
]
...
@@ -985,6 +983,7 @@
...
@@ -985,6 +983,7 @@
return
rel
return
rel
return
None
return
None
build_visitor_stub
((
SubQuery
,
And
,
Or
,
Not
,
Exists
,
Relation
,
build_visitor_stub
((
SubQuery
,
And
,
Or
,
Not
,
Exists
,
Relation
,
Comparison
,
MathExpression
,
Function
,
Constant
,
Comparison
,
MathExpression
,
Function
,
Constant
,
VariableRef
,
SortTerm
,
ColumnAlias
,
Variable
))
VariableRef
,
SortTerm
,
ColumnAlias
,
Variable
))
This diff is collapsed.
Click to expand it.
utils.py
+
19
−
0
View file @
53e9cd50
...
@@ -73,6 +73,25 @@
...
@@ -73,6 +73,25 @@
"""
Return true if the given word is a RQL keyword.
"""
"""
Return true if the given word is a RQL keyword.
"""
return
word
.
upper
()
in
KEYWORDS
return
word
.
upper
()
in
KEYWORDS
def
common_parent
(
node1
,
node2
):
"""
return the first common parent between node1 and node2
algorithm :
1) index node1
'
s parents
2) climb among node2
'
s parents until we find a common parent
"""
# index node1's parents
node1_parents
=
set
()
while
node1
:
node1_parents
.
add
(
node1
)
node1
=
node1
.
parent
# climb among node2's parents until we find a common parent
while
node2
:
if
node2
in
node1_parents
:
return
node2
node2
=
node2
.
parent
raise
Exception
(
'
DUH!
'
)
FUNCTIONS
=
_GenericAdvFuncHelper
.
FUNCTIONS
.
copy
()
FUNCTIONS
=
_GenericAdvFuncHelper
.
FUNCTIONS
.
copy
()
def
register_function
(
funcdef
):
def
register_function
(
funcdef
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment