diff --git a/product/ZSQLCatalog/Interface/ISearchKey.py b/product/ZSQLCatalog/Interface/ISearchKey.py index 8dc397b163a007e9d06c248d7fa25a5fb3d3fb3a..babdf1037ecbd3a30c9d62c3a90dbec84142c02d 100644 --- a/product/ZSQLCatalog/Interface/ISearchKey.py +++ b/product/ZSQLCatalog/Interface/ISearchKey.py @@ -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. """ diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index 73840cf54631c99ef844efc38e03ef675e477b00..c097847f1f9436a0cce93400a803e4976925ce0b 100644 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -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 diff --git a/product/ZSQLCatalog/SearchKey/RelatedKey.py b/product/ZSQLCatalog/SearchKey/RelatedKey.py index 5c092d2783343d93e6332e9182b383cf32036620..875104dc722eb63952f2e12612b5d208477656f0 100644 --- a/product/ZSQLCatalog/SearchKey/RelatedKey.py +++ b/product/ZSQLCatalog/SearchKey/RelatedKey.py @@ -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)