Commit 84582a33 authored by Romain Courteaud's avatar Romain Courteaud

buildSQLExpressionFromDomainSelection should propagate join_table and...

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
parent db2ed0e8
...@@ -426,8 +426,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -426,8 +426,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
security.declarePublic('asSQLExpression') security.declarePublic('asSQLExpression')
def asSQLExpression(self, table_map=None, domain_id=None, def asSQLExpression(self, table_map=None, domain_id=None,
exclude_domain_id=None, strict_membership=0, exclude_domain_id=None, strict_membership=0,
join_table="catalog", join_column="uid", base_category=None, join_table="catalog", join_column="uid",
category_table_alias='category'): base_category=None, category_table_alias='category'):
select_expression = [] select_expression = []
portal = self.getPortalObject() portal = self.getPortalObject()
for k, d in self.domain_dict.iteritems(): for k, d in self.domain_dict.iteritems():
...@@ -435,17 +435,21 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -435,17 +435,21 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
if k == 'parent': if k == 'parent':
# Special treatment for parent # Special treatment for parent
select_expression.append(d.getParentSQLExpression(table='catalog', select_expression.append(
d.getParentSQLExpression(table='catalog',
strict_membership=strict_membership)) strict_membership=strict_membership))
elif k is not None: elif k is not None:
if getattr(aq_base(d), 'isPredicate', 0): if getattr(aq_base(d), 'isPredicate', 0):
select_expression.append(d.asSQLExpression(table='%s_%s' % (k, category_table_alias), select_expression.append(
d.asSQLExpression(table='%s_%s' % (k, category_table_alias),
strict_membership=strict_membership)) strict_membership=strict_membership))
else: else:
# This is a category, we must join # This is a category, we must join
select_expression.append('%s.%s = %s_%s.uid' % \ select_expression.append('%s.%s = %s_%s.uid' % \
(join_table, join_column, k, category_table_alias)) (join_table, join_column,
select_expression.append(d.asSQLExpression(table='%s_%s' % (k, category_table_alias), k, category_table_alias))
select_expression.append(
d.asSQLExpression(table='%s_%s' % (k, category_table_alias),
base_category=k, base_category=k,
strict_membership=strict_membership)) strict_membership=strict_membership))
# XXX We should take into account k explicitely # XXX We should take into account k explicitely
...@@ -462,7 +466,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent): ...@@ -462,7 +466,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
asSqlExpression = asSQLExpression asSqlExpression = asSQLExpression
security.declarePublic('asSQLJoinExpression') 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 = [] join_expression = []
#LOG('DomainSelection', 0, 'domain_id = %r, exclude_domain_id = %r, self.domain_dict = %r' % (domain_id, exclude_domain_id, self.domain_dict)) #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() portal = self.getPortalObject()
......
...@@ -1236,7 +1236,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -1236,7 +1236,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
DeprecationWarning) DeprecationWarning)
else: else:
selection_domain = DomainSelection(selection_domain).__of__(self) 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') security.declarePublic('buildSQLExpressionFromDomainSelection')
def buildSQLExpressionFromDomainSelection(self, selection_domain, def buildSQLExpressionFromDomainSelection(self, selection_domain,
...@@ -1253,7 +1254,11 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -1253,7 +1254,11 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
DeprecationWarning) DeprecationWarning)
else: else:
selection_domain = DomainSelection(selection_domain).__of__(self) selection_domain = DomainSelection(selection_domain).__of__(self)
return selection_domain.asSQLExpression(strict_membership = strict_membership, 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) category_table_alias = category_table_alias)
def _aq_dynamic(self, name): def _aq_dynamic(self, name):
......
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