engine: force join to right when looking for members (#38913)
This commit is contained in:
parent
f2b6ab958a
commit
5b72a4be6d
|
@ -174,7 +174,7 @@ class EngineDimension(object):
|
|||
table_expression = '%s' % self.engine_cube.fact_table
|
||||
if joins:
|
||||
table_expression = self.engine_cube.build_table_expression(
|
||||
joins, self.engine_cube.fact_table)
|
||||
joins, self.engine_cube.fact_table, force_join='right')
|
||||
sql = 'SELECT %s AS value, %s::text AS label ' % (value, value_label)
|
||||
sql += 'FROM %s ' % table_expression
|
||||
if order_by:
|
||||
|
@ -455,7 +455,7 @@ class EngineCube(object):
|
|||
'full': 'FULL OUTER JOIN',
|
||||
}
|
||||
|
||||
def build_table_expression(self, joins, table_name):
|
||||
def build_table_expression(self, joins, table_name, force_join=None):
|
||||
'''Recursively build the table expression from the join tree,
|
||||
starting from the fact table'''
|
||||
|
||||
|
@ -464,7 +464,7 @@ class EngineCube(object):
|
|||
for join_name in joins:
|
||||
join = self.get_join(join_name)
|
||||
master_table = join.master_table or self.fact_table
|
||||
join_tree.setdefault(master_table, {}).setdefault(join.kind, {})[join.name] = join
|
||||
join_tree.setdefault(master_table, {}).setdefault(force_join or join.kind, {})[join.name] = join
|
||||
|
||||
def build_table_expression_helper(join_tree, table_name, alias=None, top=True):
|
||||
contain_joins = False
|
||||
|
|
|
@ -20,8 +20,9 @@ def test_simple(schema1, app, admin):
|
|||
response = form.submit('visualize')
|
||||
assert 'big-msg-info' not in response
|
||||
assert get_table(response) == [
|
||||
[u'Inner SubCategory', u'subé3', u'subé1'],
|
||||
['number of rows', '1', '15'],
|
||||
['Inner SubCategory', u'sub\xe94', u'sub\xe95', u'sub\xe96', u'sub\xe98',
|
||||
u'sub\xe99', u'sub\xe97', u'sub\xe92', u'sub\xe93', u'sub\xe91'],
|
||||
['number of rows', '0', '0', '0', '0', '0', '0', '0', '1', '15']
|
||||
]
|
||||
form = response.form
|
||||
form.set('representation', 'table')
|
||||
|
@ -148,7 +149,7 @@ def test_ods(schema1, app, admin):
|
|||
assert get_table(response) == get_ods_table(ods_response)[1:]
|
||||
root = get_ods_document(ods_response)
|
||||
nodes = root.findall('.//{%s}table-cell' % TABLE_NS)
|
||||
assert len([node for node in nodes if node.attrib['{%s}value-type' % OFFICE_NS] == 'float']) == 4
|
||||
assert len([node for node in nodes if node.attrib['{%s}value-type' % OFFICE_NS] == 'float']) == 11
|
||||
|
||||
app.reset() # logout
|
||||
assert 'login' in app.get(ods_response.request.url, status=302).location
|
||||
|
|
Loading…
Reference in New Issue