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
Labels
Merge Requests
141
Merge Requests
141
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
Jobs
Commits
Open sidebar
nexedi
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
Hide 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):
))
self.group_by_list = [checkColumn(x) for x in group_by_list]
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()
}
# 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 @@
#
##############################################################################
from
functools
import
partial
import
unittest
from
Products.ZSQLCatalog.SQLCatalog
import
Catalog
as
SQLCatalog
from
Products.ZSQLCatalog.SQLCatalog
import
Query
...
...
@@ -787,6 +788,15 @@ class TestSQLCatalog(ERP5TypeTestCase):
)
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': '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