From 84582a33d517262784c5b7b9c24558aaa016e0c0 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Thu, 19 Apr 2007 10:04:16 +0000 Subject: [PATCH] buildSQLExpressionFromDomainSelection should propagate join_table and join_column to keep compatiblity. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14118 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/Selection.py | 23 ++++++++++++++--------- product/ERP5Form/SelectionTool.py | 11 ++++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/product/ERP5Form/Selection.py b/product/ERP5Form/Selection.py index b8c5932b98..a924eaf365 100644 --- a/product/ERP5Form/Selection.py +++ b/product/ERP5Form/Selection.py @@ -426,8 +426,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): security.declarePublic('asSQLExpression') def asSQLExpression(self, table_map=None, domain_id=None, exclude_domain_id=None, strict_membership=0, - join_table="catalog", join_column="uid", base_category=None, - category_table_alias='category'): + join_table="catalog", join_column="uid", + base_category=None, category_table_alias='category'): select_expression = [] portal = self.getPortalObject() for k, d in self.domain_dict.iteritems(): @@ -435,17 +435,21 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): if k == 'parent': # Special treatment for parent - select_expression.append(d.getParentSQLExpression(table='catalog', - strict_membership=strict_membership)) + select_expression.append( + d.getParentSQLExpression(table='catalog', + strict_membership=strict_membership)) elif k is not None: if getattr(aq_base(d), 'isPredicate', 0): - select_expression.append(d.asSQLExpression(table='%s_%s' % (k, category_table_alias), - strict_membership=strict_membership)) + select_expression.append( + d.asSQLExpression(table='%s_%s' % (k, category_table_alias), + strict_membership=strict_membership)) else: # This is a category, we must join select_expression.append('%s.%s = %s_%s.uid' % \ - (join_table, join_column, k, category_table_alias)) - select_expression.append(d.asSQLExpression(table='%s_%s' % (k, category_table_alias), + (join_table, join_column, + k, category_table_alias)) + select_expression.append( + d.asSQLExpression(table='%s_%s' % (k, category_table_alias), base_category=k, strict_membership=strict_membership)) # XXX We should take into account k explicitely @@ -462,7 +466,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): asSqlExpression = asSQLExpression security.declarePublic('asSQLJoinExpression') - def asSQLJoinExpression(self, domain_id=None, exclude_domain_id=None, category_table_alias='category'): + def asSQLJoinExpression(self, domain_id=None, exclude_domain_id=None, + category_table_alias='category'): join_expression = [] #LOG('DomainSelection', 0, 'domain_id = %r, exclude_domain_id = %r, self.domain_dict = %r' % (domain_id, exclude_domain_id, self.domain_dict)) portal = self.getPortalObject() diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py index ce857a97dd..4a0a953a25 100644 --- a/product/ERP5Form/SelectionTool.py +++ b/product/ERP5Form/SelectionTool.py @@ -1236,7 +1236,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): DeprecationWarning) else: selection_domain = DomainSelection(selection_domain).__of__(self) - return selection_domain.asSQLJoinExpression(category_table_alias = category_table_alias) + return selection_domain.asSQLJoinExpression( + category_table_alias=category_table_alias) security.declarePublic('buildSQLExpressionFromDomainSelection') def buildSQLExpressionFromDomainSelection(self, selection_domain, @@ -1253,8 +1254,12 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): DeprecationWarning) else: selection_domain = DomainSelection(selection_domain).__of__(self) - return selection_domain.asSQLExpression(strict_membership = strict_membership, - category_table_alias = category_table_alias) + return selection_domain.asSQLExpression( + strict_membership = strict_membership, + join_table=join_table, + join_column=join_column, + base_category=base_category, + category_table_alias = category_table_alias) def _aq_dynamic(self, name): """ -- 2.30.9