Commit 78c99de3 authored by Vincent Pelletier's avatar Vincent Pelletier

ZSQLCatalog: Add inner_join_list support.

parent 40a4cdc7
......@@ -59,6 +59,7 @@ class ColumnMap(object):
catalog_table_name=None,
table_override_map=None,
left_join_list=None,
inner_join_list=None,
implicit_join=False):
self.catalog_table_name = catalog_table_name
# Key: group
......@@ -107,6 +108,10 @@ class ColumnMap(object):
assert not (self.implicit_join and self.left_join_list), (
"Cannot do left_joins while forcing implicit join"
)
self.inner_join_list = inner_join_list
assert not set(left_join_list).intersection(inner_join_list), (
"left_join_list and inner_join_list intersect"
)
def registerColumn(self, raw_column, group=DEFAULT_GROUP_ID, simple_query=None):
assert ' as ' not in raw_column.lower(), raw_column
......@@ -666,7 +671,7 @@ class ColumnMap(object):
# table aliases should cause some of these table definitions to be
# collapsed into others.
assert self._setMinimalTableDefinition()
Join = (column in self.left_join_list or
Join = column not in self.inner_join_list and (column in self.left_join_list or
(not self.implicit_join and column in self.registry.get(DEFAULT_GROUP_ID, ())))\
and LeftJoin or InnerJoin
join_definition = Join(self.table_definition, right_side,
......
......@@ -59,6 +59,7 @@ class EntireQuery(object):
group_by_list=(),
select_dict=None,
left_join_list=(),
inner_join_list=(),
limit=None,
catalog_table_name=None,
extra_column_list=(),
......@@ -71,6 +72,7 @@ class EntireQuery(object):
self.group_by_list = list(group_by_list)
self.select_dict = defaultDict(select_dict)
self.left_join_list = left_join_list
self.inner_join_list = inner_join_list
self.limit = limit
self.catalog_table_name = catalog_table_name
self.extra_column_list = list(extra_column_list)
......@@ -89,6 +91,7 @@ class EntireQuery(object):
column_map = ColumnMap(catalog_table_name=self.catalog_table_name,
table_override_map=self.from_expression,
left_join_list=self.left_join_list,
inner_join_list=self.inner_join_list,
implicit_join=self.implicit_join,
)
self.column_map = column_map
......
......@@ -2366,6 +2366,7 @@ class Catalog(Folder,
select_dict = kw.pop('select_dict', {})
# Handle left_join_list
left_join_list = kw.pop('left_join_list', ())
inner_join_list = kw.pop('inner_join_list', ())
# Handle implicit_join. It's True by default, as there's a lot of code
# in BT5s and elsewhere that calls buildSQLQuery() expecting implicit
# join. self._queryResults() defaults it to False for those using
......@@ -2393,6 +2394,7 @@ class Catalog(Folder,
group_by_list=group_by_list,
select_dict=select_dict,
left_join_list=left_join_list,
inner_join_list=inner_join_list,
implicit_join=implicit_join,
limit=limit,
catalog_table_name=query_table,
......
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