Commit ee7c10dd authored by Sebastien Robin's avatar Sebastien Robin

allow to give query strings with ComplexQuery instead of only Query instances


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14079 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29979ca7
...@@ -440,7 +440,8 @@ class ComplexQuery(QueryMixin): ...@@ -440,7 +440,8 @@ class ComplexQuery(QueryMixin):
def getRelatedTableMapDict(self): def getRelatedTableMapDict(self):
result = {} result = {}
for query in self.getQueryList(): for query in self.getQueryList():
result.update(query.getRelatedTableMapDict()) if not(isinstance(query, basestring)):
result.update(query.getRelatedTableMapDict())
return result return result
def asSQLExpression(self, key_alias_dict=None, def asSQLExpression(self, key_alias_dict=None,
...@@ -454,16 +455,19 @@ class ComplexQuery(QueryMixin): ...@@ -454,16 +455,19 @@ class ComplexQuery(QueryMixin):
sql_expression_list = [] sql_expression_list = []
select_expression_list = [] select_expression_list = []
for query in self.getQueryList(): for query in self.getQueryList():
query_result = query.asSQLExpression( key_alias_dict=key_alias_dict, if isinstance(query, basestring):
ignore_empty_string=ignore_empty_string, sql_expression_list.append(query)
keyword_search_keys=keyword_search_keys, else:
full_text_search_keys=full_text_search_keys, query_result = query.asSQLExpression( key_alias_dict=key_alias_dict,
stat__=stat__) ignore_empty_string=ignore_empty_string,
sql_expression_list.append(query_result['where_expression']) keyword_search_keys=keyword_search_keys,
select_expression_list.extend(query_result['select_expression_list']) full_text_search_keys=full_text_search_keys,
stat__=stat__)
sql_expression_list.append(query_result['where_expression'])
select_expression_list.extend(query_result['select_expression_list'])
operator = self.getOperator() operator = self.getOperator()
result = {'where_expression':('(%s)' % \ result = {'where_expression':('(%s)' % \
(' %s ' % operator).join(sql_expression_list)), (' %s ' % operator).join(['(%s)' % x for x in sql_expression_list])),
'select_expression_list':select_expression_list} 'select_expression_list':select_expression_list}
return result return result
...@@ -474,7 +478,8 @@ class ComplexQuery(QueryMixin): ...@@ -474,7 +478,8 @@ class ComplexQuery(QueryMixin):
""" """
key_list=[] key_list=[]
for query in self.getQueryList(): for query in self.getQueryList():
key_list.extend(query.getSQLKeyList()) if not(isinstance(query, basestring)):
key_list.extend(query.getSQLKeyList())
return key_list return key_list
allow_class(ComplexQuery) allow_class(ComplexQuery)
......
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