Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
erp5
Commits
be816eed
Commit
be816eed
authored
Aug 22, 2013
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ColumnMap: use complex sql function as column name
also fix default value search in related_key_dict
parent
df06708b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
product/ZSQLCatalog/ColumnMap.py
product/ZSQLCatalog/ColumnMap.py
+7
-5
No files found.
product/ZSQLCatalog/ColumnMap.py
View file @
be816eed
...
...
@@ -50,6 +50,7 @@ MAPPING_TRACE = False
# TODO: rename all "related_key" references into "virtual_column"
re_sql_as
=
re
.
compile
(
"
\
s+AS
\
s[^)]+$"
,
re
.
IGNORECASE
|
re
.
MULTILINE
)
re_sql_function_column
=
re
.
compile
(
"([
\
s
\
w
\
(]*
\
()
\
s*([`
\
s*
\
w.]*)
\
s*([=,
\
)][=,
\
)+-:%'
\
"
\
s
\
w]*)"
)
class
ColumnMap
(
object
):
...
...
@@ -114,10 +115,10 @@ class ColumnMap(object):
# XXX This is not enough to parse something like:
# GROUP_CONCAT(DISTINCT foo ORDER BY bar)
if
'('
in
raw_column
:
function
,
column
=
raw_column
.
split
(
'('
)
__traceback_info__
=
raw_column
function_begin
,
column
,
function_end
=
re_sql_function_column
.
match
(
raw_column
).
groups
()
column
=
column
.
strip
()
assert
column
[
-
1
]
==
')'
,
column
column
=
column
[:
-
1
].
strip
()
function
=
function_begin
.
strip
(),
function_end
.
strip
()
else
:
function
=
None
column
=
raw_column
...
...
@@ -465,14 +466,15 @@ class ColumnMap(object):
column_suffix
=
''
function
,
column
=
self
.
raw_column_dict
.
get
(
raw_column
,
(
None
,
raw_column
))
if
group
is
DEFAULT_GROUP_ID
:
group
,
column
=
self
.
related_key_dict
.
get
(
column
,
(
group
,
raw_
column
))
group
,
column
=
self
.
related_key_dict
.
get
(
column
,
(
group
,
column
))
alias
=
self
.
table_alias_dict
[(
group
,
self
.
column_map
[(
group
,
column
)])]
if
column_suffix
:
result
=
'%s_%s%s'
%
(
alias
,
column
,
column_suffix
)
else
:
result
=
'`%s`.`%s`'
%
(
alias
,
column
)
if
function
is
not
None
:
result
=
'%s(%s)'
%
(
function
,
result
)
function_begin
,
function_end
=
function
result
=
""
.
join
((
function_begin
,
result
,
function_end
))
return
result
def
getCatalogTableAlias
(
self
,
group
=
DEFAULT_GROUP_ID
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment