Commit 11425a28 authored by Vincent Pelletier's avatar Vincent Pelletier

Do not delegate join_condition query creation to RelatedKey.buildQuery.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25879 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d3656fab
......@@ -155,7 +155,7 @@ class IRelatedKey(ISearchKey):
Used to retrieve related key's ZSQLMethod.
"""
def buildQuery(sql_catalog, related_key_definition, search_value=None, search_key_name=None, logical_operator=None, comparison_operator=None):
def buildQuery(sql_catalog, related_key_definition, search_value=None):
"""
group is useless here, since group is determined by ColumnMap at
registration time. search_value becomes optional.
......@@ -171,20 +171,10 @@ class IRelatedKey(ISearchKey):
Table names are separated by ','
- a column name
- the name of the related key ZSQLMethod
search_value (anything)
search_value (None or Query)
If given, a condition on real column will be generated.
Otherwise, only the SQL required to reach that column will be
generated. This is useful when sorting on a virtual column, for
example.
search_key_name (string, None)
If given, it overrides real column's default SearchKey.
logical_operator (string, None)
If given, expresses the default logical link between operands.
It must be one of None, 'or' and 'and'.
It is overriden by operator present in search_value if it is a dict
and contains an 'operator' key.
'or' is assumed if not given or given with a None value.
comparison_operator (string, None)
If given, expresses the comparison between column and value.
"""
......@@ -1903,9 +1903,15 @@ class Catalog(Folder,
result = None
else:
if related_key_definition is None:
result = search_key.buildQuery(value, logical_operator=logical_operator, comparison_operator=comparison_operator)
build_key = search_key
else:
result = search_key.buildQuery(search_value=value, sql_catalog=self, search_key_name=search_key_name, related_key_definition=related_key_definition, logical_operator=logical_operator, comparison_operator=comparison_operator)
build_key = search_key.getSearchKey(self, related_key_definition,
search_key_name=search_key_name)
result = build_key.buildQuery(value, logical_operator=logical_operator,
comparison_operator=comparison_operator)
if related_key_definition is not None:
result = search_key.buildQuery(self, related_key_definition,
search_value=result)
else:
result = script(value)
return result
......
......@@ -38,7 +38,6 @@ from Products.ZSQLCatalog.Interface.ISearchKey import IRelatedKey
from Interface.Verify import verifyClass
from Products.ZSQLCatalog.SQLCatalog import profiler_decorator
MARKER = []
BACKWARD_COMPATIBILITY = True
class RelatedKey(SearchKey):
......@@ -104,16 +103,11 @@ class RelatedKey(SearchKey):
@profiler_decorator
def buildQuery(self, sql_catalog, related_key_definition,
search_value=MARKER, search_key_name=None,
logical_operator=None, comparison_operator=None):
search_value=None):
self._buildRelatedKey(related_key_definition)
if search_value is MARKER:
join_condition = None
else:
join_condition = self._getSearchKey(sql_catalog, search_key_name).buildQuery(
search_value, group=self.getColumn(),
logical_operator=logical_operator,
comparison_operator=comparison_operator)
if isinstance(search_value, Query):
search_value.setGroup(self.getColumn())
join_condition = search_value
return RelatedQuery(search_key=self,
join_condition=join_condition)
......
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