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
Xavier Thompson
erp5
Commits
8cf3fc36
Commit
8cf3fc36
authored
Apr 24, 2019
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZSQLCatalog: Fix support for select_list=['count(*)'] .
parent
fc693a8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
product/ZSQLCatalog/Query/EntireQuery.py
product/ZSQLCatalog/Query/EntireQuery.py
+5
-1
product/ZSQLCatalog/tests/testSQLCatalog.py
product/ZSQLCatalog/tests/testSQLCatalog.py
+10
-0
No files found.
product/ZSQLCatalog/Query/EntireQuery.py
View file @
8cf3fc36
...
@@ -115,7 +115,11 @@ class EntireQuery(object):
...
@@ -115,7 +115,11 @@ class EntireQuery(object):
))
))
self.group_by_list = [checkColumn(x) for x in group_by_list]
self.group_by_list = [checkColumn(x) for x in group_by_list]
self.select_dict = {
self.select_dict = {
checkIdentifier(alias): checkSelectable(column)
# Ideally, keys should only satisfy checkIdentifier, but as SQLCatalog
# builds select_dict from select_list in which case keys equal values,
# so align with the lowest denominator: selectable also cover columns,
# which when there is no table name is an identifier.
checkSelectable(alias): checkSelectable(column)
for alias, column in defaultDict(select_dict).iteritems()
for alias, column in defaultDict(select_dict).iteritems()
}
}
# No need to sanitize, it'
s
compared
against
columns
and
not
included
in
SQL
# No need to sanitize, it'
s
compared
against
columns
and
not
included
in
SQL
...
...
product/ZSQLCatalog/tests/testSQLCatalog.py
View file @
8cf3fc36
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#
#
##############################################################################
##############################################################################
from
functools
import
partial
import
unittest
import
unittest
from
Products.ZSQLCatalog.SQLCatalog
import
Catalog
as
SQLCatalog
from
Products.ZSQLCatalog.SQLCatalog
import
Catalog
as
SQLCatalog
from
Products.ZSQLCatalog.SQLCatalog
import
Query
from
Products.ZSQLCatalog.SQLCatalog
import
Query
...
@@ -787,6 +788,15 @@ class TestSQLCatalog(ERP5TypeTestCase):
...
@@ -787,6 +788,15 @@ class TestSQLCatalog(ERP5TypeTestCase):
)
)
self
.
assertEqual
(
order_by_list
,
[[
'default'
,
'DESC'
,
'INT'
]])
self
.
assertEqual
(
order_by_list
,
[[
'default'
,
'DESC'
,
'INT'
]])
def
test_selectSyntaxConstraint
(
self
):
buildSQLQuery
=
self
.
_catalog
.
buildSQLQuery
# Verify SQLCatalog accepts "count(*)" in select_list, which results in
# {'count(*)': None} . While not exactly a feature, there should be no
# reason to break this.
buildSQLQuery
(
select_list
=
[
'count(*)'
])
buildSQLQuery
(
select_dict
=
{
'count(*)'
:
None
})
buildSQLQuery
(
select_dict
=
{
'count(*)'
:
'count(*)'
})
##return catalog(title=Query(title='a', operator='not'))
##return catalog(title=Query(title='a', operator='not'))
#return catalog(title={'query': 'a', 'operator': 'not'})
#return catalog(title={'query': 'a', 'operator': 'not'})
#return catalog(title={'query': ['a', 'b'], '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