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