Commit 0171bb8d authored by Romain Courteaud's avatar Romain Courteaud

Added parameter join_table and join_column to asSqlExpression.

Changed code layout.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5026 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a6ad8241
......@@ -378,16 +378,21 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
return
security.declarePublic('asSqlExpression')
def asSqlExpression(self, table_map=None, domain_id=None, exclude_domain_id=None, strict_membership=0):
def asSqlExpression(self, table_map=None, domain_id=None,
exclude_domain_id=None, strict_membership=0,
join_table="catalog", join_column="uid"):
join_expression = []
for k, d in self.domain_dict.items():
if k == 'parent':
# Special treatment for parent
join_expression.append(d.getParentSqlExpression(table = 'catalog', strict_membership=strict_membership))
join_expression.append(d.getParentSqlExpression(table='catalog',
strict_membership=strict_membership))
elif k is not None and getattr(aq_base(d), 'isCategory', 0):
# This is a category, we must join
join_expression.append('catalog.uid = %s_category.uid' % k)
join_expression.append(d.asSqlExpression(table = '%s_category' % k, strict_membership=strict_membership))
join_expression.append('%s.%s = %s_category.uid' % \
(join_table, join_column, k))
join_expression.append(d.asSqlExpression(table='%s_category' % k,
strict_membership=strict_membership))
result = "( %s )" % ' AND '.join(join_expression)
#LOG('asSqlExpression', 0, str(result))
return result
......
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