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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
erp5
Commits
53e83f36
Commit
53e83f36
authored
Oct 05, 2015
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve buildOrderByList() that now returns a more structured result with order_by_expression.
parent
a2759acd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+7
-1
product/ZSQLCatalog/tests/testSQLCatalog.py
product/ZSQLCatalog/tests/testSQLCatalog.py
+30
-0
No files found.
product/ZSQLCatalog/SQLCatalog.py
View file @
53e83f36
...
...
@@ -2346,7 +2346,13 @@ class Catalog(Folder,
elif
order_by_expression
is
not
None
:
if
not
isinstance
(
order_by_expression
,
basestring
):
raise
TypeError
,
'order_by_expression must be a basestring instance. Got %r.'
%
(
order_by_expression
,
)
order_by_list
=
[[
x
.
strip
()]
for
x
in
order_by_expression
.
split
(
','
)]
for
x
in
order_by_expression
.
split
(
','
):
x
=
x
.
strip
()
item
=
x
.
rsplit
(
None
,
1
)
if
len
(
item
)
>
1
and
item
[
-
1
].
upper
()
in
(
'ASC'
,
'DESC'
):
append
(
item
)
else
:
append
([
x
])
return
order_by_list
def
buildEntireQuery
(
self
,
kw
,
query_table
=
'catalog'
,
ignore_empty_string
=
1
,
...
...
product/ZSQLCatalog/tests/testSQLCatalog.py
View file @
53e83f36
...
...
@@ -791,6 +791,36 @@ class TestSQLCatalog(ERP5TypeTestCase):
self
.
_searchTextInDictQuery
(
'date'
)
self
.
_searchTextInDictQuery
(
'related_date'
)
def
test_buildOrderByList
(
self
):
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
sort_on
=
'default'
,
)
self
.
assertEqual
(
order_by_list
,
[[
'default'
]])
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
sort_on
=
'default'
,
sort_order
=
'DESC'
,
)
self
.
assertEqual
(
order_by_list
,
[[
'default'
,
'DESC'
]])
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
sort_on
=
[[
'default'
,
'DESC'
,
'INT'
]]
)
self
.
assertEqual
(
order_by_list
,
[[
'default'
,
'DESC'
,
'INT'
]])
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
order_by_expression
=
'default'
)
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
order_by_expression
=
'default DESC'
)
self
.
assertEqual
(
order_by_list
,
[[
'default'
,
'DESC'
]])
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
order_by_expression
=
'CAST(default AS INT) DESC'
)
self
.
assertEqual
(
order_by_list
,
[[
'CAST(default AS INT)'
,
'DESC'
]])
order_by_list
=
self
.
_catalog
.
buildOrderByList
(
order_by_expression
=
'CAST(default AS INT)'
)
self
.
assertEqual
(
order_by_list
,
[[
'CAST(default AS INT)'
]])
##return catalog(title=Query(title='a', operator='not'))
#return catalog(title={'query': 'a', 'operator': 'not'})
#return catalog(title={'query': ['a', 'b'], 'operator': 'not'})
...
...
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