From f0deb3b23bf7d6b982841b0eb02c06a67371b2ae Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 14 Jan 2020 17:34:38 +0100 Subject: [PATCH 2/3] engine: force join to right when looking for members (#38913) --- bijoe/engine.py | 6 +++--- tests/test_schema1.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bijoe/engine.py b/bijoe/engine.py index d76f429..4bc648c 100644 --- a/bijoe/engine.py +++ b/bijoe/engine.py @@ -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 diff --git a/tests/test_schema1.py b/tests/test_schema1.py index 9a46944..4decb0b 100644 --- a/tests/test_schema1.py +++ b/tests/test_schema1.py @@ -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 -- 2.24.0