Commit 958c3b87 authored by Vincent Pelletier's avatar Vincent Pelletier

SQLCatalog: Stop relying on portal_selections for SQL expression generation

parent 68de872c
......@@ -13,31 +13,11 @@ FROM
<dtml-else>
<dtml-in from_table_list> <dtml-var sequence-item> AS <dtml-var sequence-key><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
</dtml-if>
<dtml-if selection_domain>
<dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias = 'domain_category')">
<dtml-if expression> , <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
<dtml-if selection_report>
<dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias = 'report_category')">
<dtml-if expression> , <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
WHERE
1 = 1
<dtml-if where_expression>
AND <dtml-var where_expression>
</dtml-if>
<dtml-if selection_domain>
<dtml-let expression="portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, category_table_alias = 'domain_category')">
<dtml-if expression> AND <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
<dtml-if selection_report>
<dtml-let expression="portal_selections.buildSQLExpressionFromDomainSelection(selection_report, strict_membership=1, category_table_alias = 'report_category')">
<dtml-if expression> AND <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
<dtml-if sort_on>
ORDER BY
<dtml-var sort_on>
......
......@@ -14,9 +14,7 @@
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>selection_domain\r\n
selection_report\r\n
where_expression\r\n
<value> <string>where_expression\r\n
select_expression\r\n
group_by_expression\r\n
from_table_list:list\r\n
......
......@@ -8,32 +8,12 @@ FROM
<dtml-else>
<dtml-in from_table_list> <dtml-var sequence-item> AS <dtml-var sequence-key><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>
</dtml-if>
<dtml-if selection_domain>
<dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias = 'domain_category')">
<dtml-if expression> , <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
<dtml-if selection_report>
<dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias = 'report_category')">
<dtml-if expression> , <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
WHERE
1 = 1
<dtml-if where_expression>
AND <dtml-var where_expression>
</dtml-if>
<dtml-if selection_domain>
<dtml-let expression="portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, category_table_alias = 'domain_category')">
<dtml-if expression> AND <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
<dtml-if selection_report>
<dtml-let expression="portal_selections.buildSQLExpressionFromDomainSelection(selection_report, strict_membership=1, category_table_alias = 'report_category')">
<dtml-if expression> AND <dtml-var expression> </dtml-if>
</dtml-let>
</dtml-if>
<dtml-if group_by_expression>
GROUP BY
<dtml-var group_by_expression>
......
......@@ -14,9 +14,7 @@
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>selection_domain\r\n
selection_report\r\n
where_expression\r\n
<value> <string>where_expression\r\n
select_expression\r\n
group_by_expression\r\n
from_table_list:list\r\n
......
......@@ -143,6 +143,10 @@ else:
UID_BUFFER_SIZE = 300
OBJECT_LIST_SIZE = 300 # XXX 300 is arbitrary value of catalog object list
MAX_PATH_LEN = 255
DOMAIN_STRICT_MEMBERSHIP_DICT = {
'selection_domain': False,
'selection_report': True,
}
manage_addSQLCatalogForm = DTMLFile('dtml/addSQLCatalog',globals())
......@@ -2229,6 +2233,13 @@ class Catalog(Folder,
empty_value_dict = {}
for key, value in kw.iteritems():
result = None
if key in DOMAIN_STRICT_MEMBERSHIP_DICT:
if value is None:
continue
value = self.getPortalObject().portal_selections.asDomainQuery(
value,
strict_membership=DOMAIN_STRICT_MEMBERSHIP_DICT[key],
)
if isinstance(value, dict_type_list):
# Cast dict-ish types into plain dicts.
value = dict(value)
......@@ -2547,8 +2558,6 @@ class Catalog(Folder,
REQUEST=None,
src__=0,
build_sql_query_method=None,
selection_domain=None,
selection_report=None,
# XXX should get zsql_brain from ZSQLMethod class itself
zsql_brain=None,
implicit_join=False,
......@@ -2564,8 +2573,8 @@ class Catalog(Folder,
return sql_method(
src__=src__,
zsql_brain=zsql_brain,
selection_domain=selection_domain,
selection_report=selection_report,
selection_domain=None, # BBB
selection_report=None, # BBB
where_expression=query['where_expression'],
select_expression=query['select_expression'],
group_by_expression=query['group_by_expression'],
......
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