Commit af45c4c8 authored by Jérome Perrin's avatar Jérome Perrin

more s/Sql/SQL/g



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11880 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 813bc285
......@@ -167,8 +167,8 @@ class Predicate(Folder):
return result
security.declareProtected( Permissions.AccessContentsInformation,
'buildSqlQuery' )
def buildSqlQuery(self, strict_membership=0, table='category',
'buildSQLQuery' )
def buildSQLQuery(self, strict_membership=0, table='category',
join_table='catalog', join_column='uid'):
"""
A Predicate can be rendered as an SQL expression. This
......@@ -193,7 +193,7 @@ class Predicate(Folder):
if category_value is not None:
table_alias = "single_%s_%s" % (table, base_category)
from_table_dict[table_alias] = 'category'
membership_dict[base_category].append(category_value.asSqlExpression(
membership_dict[base_category].append(category_value.asSQLExpression(
strict_membership=strict_membership,
table=table_alias,
base_category=base_category))
......@@ -214,7 +214,7 @@ class Predicate(Folder):
join_count += 1
table_alias = "multi_%s_%s" % (table, join_count)
from_table_dict[table_alias] = 'category'
multimembership_dict[base_category].append(category_value.asSqlExpression(
multimembership_dict[base_category].append(category_value.asSQLExpression(
strict_membership=strict_membership,
table=table_alias,
base_category=base_category))
......@@ -232,17 +232,17 @@ class Predicate(Folder):
return { 'from_table_list' : from_table_dict.items(),
'where_expression' : sql_text }
security.declareProtected( Permissions.AccessContentsInformation, 'asSqlExpression' )
def asSqlExpression(self, strict_membership=0, table='category'):
security.declareProtected( Permissions.AccessContentsInformation, 'asSQLExpression' )
def asSQLExpression(self, strict_membership=0, table='category'):
"""
"""
return self.buildSqlQuery(strict_membership=strict_membership, table=table)['where_expression']
return self.buildSQLQuery(strict_membership=strict_membership, table=table)['where_expression']
security.declareProtected( Permissions.AccessContentsInformation, 'asSqlJoinExpression' )
def asSqlJoinExpression(self, strict_membership=0, table='category', join_table='catalog', join_column='uid'):
security.declareProtected( Permissions.AccessContentsInformation, 'asSQLJoinExpression' )
def asSQLJoinExpression(self, strict_membership=0, table='category', join_table='catalog', join_column='uid'):
"""
"""
table_list = self.buildSqlQuery(strict_membership=strict_membership, table=table)['from_table_list']
table_list = self.buildSQLQuery(strict_membership=strict_membership, table=table)['from_table_list']
sql_text_list = map(lambda (a,b): '%s AS %s' % (b,a), table_list)
return ' , '.join(sql_text_list)
......
......@@ -359,8 +359,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
SQL expressions to feed the SQL method (or the catalog). This
is the recommended approach.
<dtml-var "selection.domain.asSqlExpression(table_map=(('eip','movement'), ('group', 'catalog')))">
<dtml-var "selection.domain.asSqlJoinExpression(table_map=(('eip','movement'), ('group', 'catalog')))">
<dtml-var "selection.domain.asSQLExpression(table_map=(('eip','movement'), ('group', 'catalog')))">
<dtml-var "selection.domain.asSQLJoinExpression(table_map=(('eip','movement'), ('group', 'catalog')))">
Example 3: (mixed)
......@@ -368,7 +368,7 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
code generation is invoked on it. This is better than the manual
approach.
<dtml-var "selection.domain.eip.asSqlExpresion(table="resource_category")">
<dtml-var "selection.domain.eip.asSQLExpresion(table="resource_category")">
Current implementation is only suitable for categories.
It needs to be extended to support also predicates. The right approach
......@@ -417,8 +417,8 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
return obj
security.declarePublic('asSqlExpression')
def asSqlExpression(self, table_map=None, domain_id=None,
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):
select_expression = []
......@@ -432,13 +432,13 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
strict_membership=strict_membership))
elif k is not None:
if getattr(aq_base(d), 'isPredicate', 0):
select_expression.append(d.asSqlExpression(table='%s_category' % k,
select_expression.append(d.asSQLExpression(table='%s_category' % k,
strict_membership=strict_membership))
else:
# This is a category, we must join
select_expression.append('%s.%s = %s_category.uid' % \
(join_table, join_column, k))
select_expression.append(d.asSqlExpression(table='%s_category' % k,
select_expression.append(d.asSQLExpression(table='%s_category' % k,
base_category=k,
strict_membership=strict_membership))
# XXX We should take into account k explicitely
......@@ -447,11 +447,11 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
result = "( %s )" % ' AND '.join(select_expression)
else:
result = ''
#LOG('DomainSelection', 0, 'asSqlExpression returns %r' % (result,))
#LOG('DomainSelection', 0, 'asSQLExpression returns %r' % (result,))
return result
security.declarePublic('asSqlJoinExpression')
def asSqlJoinExpression(self, domain_id=None, exclude_domain_id=None):
security.declarePublic('asSQLJoinExpression')
def asSQLJoinExpression(self, domain_id=None, exclude_domain_id=None):
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()
......@@ -462,12 +462,12 @@ class DomainSelection(Acquisition.Implicit, Traversable, Persistent):
pass
elif k is not None:
if getattr(aq_base(d), 'isPredicate', 0):
join_expression.append(d.asSqlJoinExpression(table='%s_category' % k))
join_expression.append(d.asSQLJoinExpression(table='%s_category' % k))
else:
# This is a category, we must join
join_expression.append('category AS %s_category' % k)
result = "%s" % ' , '.join(join_expression)
#LOG('DomainSelection', 0, 'asSqlJoinExpression returns %r' % (result,))
#LOG('DomainSelection', 0, 'asSQLJoinExpression returns %r' % (result,))
return result
security.declarePublic('asDomainDict')
......
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