Commit 8cf3fc36 authored by Vincent Pelletier's avatar Vincent Pelletier

ZSQLCatalog: Fix support for select_list=['count(*)'] .

parent fc693a8b
......@@ -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
......
......@@ -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'})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment