Disable explicit join if table aliases are requested

Fall back to implicit joins in this case.

We'd have to implement the collapsing of inner-joins contained inside other
inner-joins based on similar aliases, and consolidate their join conditions, before
allowing table aliases with explicit joins.

This commit reverts:
 631cab2b
 93cf49e4
parent 9fdc96f3
......@@ -112,9 +112,7 @@ class DomainTool(BaseTool):
if x.startswith('predicate.')]
expression_list = []
checked_column_list = []
# XXX-Leo: Please remove implicit_join below, while making sure
# testDomainTool.py still passes
sql_kw = dict(implicit_join=True)
sql_kw = {}
query_list = []
if query is not None:
query_list = [query]
......
......@@ -562,9 +562,6 @@ class SimulationTool(BaseTool):
new_kw.pop('ignore_group_by', None)
new_kw.pop('movement_list_mode', None)
# block use of explicit join
new_kw['implicit_join'] = True
sql_kw.update(ctool.buildSQLQuery(**new_kw))
return sql_kw
......@@ -801,8 +798,7 @@ class SimulationTool(BaseTool):
where_expression = self.getPortalObject().portal_categories\
.buildSQLSelector(
category_list = variation_category,
query_table = 'predicate_category',
implicit_join=True)
query_table = 'predicate_category')
if where_expression != '':
add_kw['where_expression'] = where_expression
add_kw['predicate_category.uid'] = '!=NULL'
......@@ -1312,7 +1308,6 @@ class SimulationTool(BaseTool):
'range': column_value_dict.get('date', {}).get('range', [])
},
'query_table': None,
'implicit_join': True,
})
if date_query_result['where_expression'] not in ('',None):
where_expression = date_query_result['where_expression']
......@@ -1399,8 +1394,8 @@ class SimulationTool(BaseTool):
assert len(equal_date_query_list) == \
len(greater_than_date_query_list)
assert len(equal_date_query_list) > 0
equal_date_query = buildSQLQuery(query=ComplexQuery(operator='OR', *equal_date_query_list), query_table=None, implicit_join=True)['where_expression']
greater_than_date_query = buildSQLQuery(query=ComplexQuery(operator='OR', *greater_than_date_query_list), query_table=None, implicit_join=True)['where_expression']
equal_date_query = buildSQLQuery(query=ComplexQuery(operator='OR', *equal_date_query_list), query_table=None)['where_expression']
greater_than_date_query = buildSQLQuery(query=ComplexQuery(operator='OR', *greater_than_date_query_list), query_table=None)['where_expression']
inventory_stock_sql_kw = \
self._generateSQLKeywordDictFromKeywordDict(
table=EQUAL_DATE_TABLE_ID, sql_kw=sql_kw, new_kw=new_kw)
......
......@@ -53,6 +53,10 @@ RELATED_QUERY_SEPARATOR. \n\
Offending related key: %r, for column %r, table_alias_list: %r, \
rendered_related_key: \n%s"
RELATED_KEY_ALIASED_MESSAGE = "\
Support for explicit joins of aliased related keys is not yet implemented. \
Offending related key: %r, for column %r, table_alias_list: %r"
class RelatedKey(SearchKey):
"""
This SearchKey handles searches on virtual columns of RelatedKey type.
......@@ -128,13 +132,23 @@ class RelatedKey(SearchKey):
def registerColumnMap(self, column_map, table_alias_list=None):
related_column = self.getColumn()
group = column_map.registerRelatedKey(related_column, self.real_column)
# Each table except last one must be registered to their own group, so that
# the same table can be used multiple time (and aliased multiple times)
# in the same related key. The last one must be register to the related key
# "main" group (ie, the value of the "group" variable) to be the same as
# the table used in join_condition.
# Each table except last one must be registered to their own
# group, so that the same table can be used multiple times (and
# aliased multiple times) in the same related key. The last one
# must be registered to the related key "main" group (ie, the
# value of the "group" variable) to be the same as the table used
# in join_condition.
if table_alias_list is not None:
assert len(self.table_list) == len(table_alias_list)
# XXX-Leo: remove the rest of this 'if' branch after making sure
# that ColumnMap.addRelatedKeyJoin() can handle collapsing
# chains of inner-joins that are subsets of one another based on
# having the same aliases:
msg = RELATED_KEY_ALIASED_MESSAGE % (self.related_key_id,
self.column,
table_alias_list,)
log.warning(msg + "\n\nForcing implicit join...")
column_map.implicit_join = True
for table_position in xrange(len(self.table_list) - 1):
table_name = self.table_list[table_position]
local_group = column_map.registerRelatedKeyColumn(related_column, table_position, group)
......
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