diff --git a/product/ZSQLCatalog/Query/EntireQuery.py b/product/ZSQLCatalog/Query/EntireQuery.py index 37eee743dd70fdafbf4d8b05e42deb07cd2f42da..3cdc41839fe78bcf0df19d921923e181dd7ea71b 100644 --- a/product/ZSQLCatalog/Query/EntireQuery.py +++ b/product/ZSQLCatalog/Query/EntireQuery.py @@ -35,6 +35,12 @@ from Products.ZSQLCatalog.Interface.IEntireQuery import IEntireQuery from Interface.Verify import verifyClass from Products.ZSQLCatalog.SQLCatalog import profiler_decorator +def defaultDict(value): + if value is None: + return {} + assert isinstance(value, dict) + return value + class EntireQuery(object): """ This is not a Query subclass, since it does not define a @@ -47,28 +53,18 @@ class EntireQuery(object): column_map = None @profiler_decorator - def __init__(self, query, order_by_list=None, group_by_list=None, + def __init__(self, query, order_by_list=(), group_by_list=(), select_dict=None, limit=None, catalog_table_name=None, - extra_column_list=None, from_expression=None, + extra_column_list=(), from_expression=None, order_by_override_list=None): - def default(value): - if value is None: - return [] - assert isinstance(value, (tuple, list)) - return value - def defaultDict(value): - if value is None: - return {} - assert isinstance(value, dict) - return value self.query = query - self.order_by_list = default(order_by_list) - self.order_by_override_set = frozenset(default(order_by_override_list)) - self.group_by_list = default(group_by_list) + self.order_by_list = list(order_by_list) + self.order_by_override_set = frozenset(order_by_override_list) + self.group_by_list = list(group_by_list) self.select_dict = defaultDict(select_dict) self.limit = limit self.catalog_table_name = catalog_table_name - self.extra_column_list = default(extra_column_list) + self.extra_column_list = list(extra_column_list) self.from_expression = from_expression def asSearchTextExpression(self, sql_catalog): diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index d1d47e9782b4a49cb2f49e820b7dfc2eb39ba427..e66155d6b04e01c9fe0541f1f51de0bc9fcef166 100644 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -2094,9 +2094,9 @@ class Catalog(Folder, @profiler_decorator def buildSQLQuery(self, query_table='catalog', REQUEST=None, ignore_empty_string=1, only_group_columns=False, - limit=None, extra_column_list=None, + limit=None, extra_column_list=(), **kw): - group_by_list = kw.pop('group_by_list', kw.pop('group_by', kw.pop('group_by_expression', None))) + group_by_list = kw.pop('group_by_list', kw.pop('group_by', kw.pop('group_by_expression', ()))) if isinstance(group_by_list, basestring): group_by_list = [x.strip() for x in group_by_list.split(',')] select_dict = kw.pop('select_dict', kw.pop('select_list', kw.pop('select_expression', None))) @@ -2144,7 +2144,7 @@ class Catalog(Folder, # It is required to support select_expression_key parameter for backward # compatiblity, but I'm not sure if there can be a serious use for it in # new API. - order_by_override_list = kw.pop('select_expression_key', None) + order_by_override_list = kw.pop('select_expression_key', ()) query = EntireQuery( query=self.buildQuery(kw, ignore_empty_string=ignore_empty_string), order_by_list=order_by_list,