0002-engine-force-join-to-right-when-looking-for-members-.patch
bijoe/engine.py | ||
---|---|---|
174 | 174 |
table_expression = '%s' % self.engine_cube.fact_table |
175 | 175 |
if joins: |
176 | 176 |
table_expression = self.engine_cube.build_table_expression( |
177 |
joins, self.engine_cube.fact_table) |
|
177 |
joins, self.engine_cube.fact_table, force_join='right')
|
|
178 | 178 |
sql = 'SELECT %s AS value, %s::text AS label ' % (value, value_label) |
179 | 179 |
sql += 'FROM %s ' % table_expression |
180 | 180 |
if order_by: |
... | ... | |
455 | 455 |
'full': 'FULL OUTER JOIN', |
456 | 456 |
} |
457 | 457 | |
458 |
def build_table_expression(self, joins, table_name): |
|
458 |
def build_table_expression(self, joins, table_name, force_join=None):
|
|
459 | 459 |
'''Recursively build the table expression from the join tree, |
460 | 460 |
starting from the fact table''' |
461 | 461 | |
... | ... | |
464 | 464 |
for join_name in joins: |
465 | 465 |
join = self.get_join(join_name) |
466 | 466 |
master_table = join.master_table or self.fact_table |
467 |
join_tree.setdefault(master_table, {}).setdefault(join.kind, {})[join.name] = join |
|
467 |
join_tree.setdefault(master_table, {}).setdefault(force_join or join.kind, {})[join.name] = join
|
|
468 | 468 | |
469 | 469 |
def build_table_expression_helper(join_tree, table_name, alias=None, top=True): |
470 | 470 |
contain_joins = False |
tests/test_schema1.py | ||
---|---|---|
20 | 20 |
response = form.submit('visualize') |
21 | 21 |
assert 'big-msg-info' not in response |
22 | 22 |
assert get_table(response) == [ |
23 |
[u'Inner SubCategory', u'subé3', u'subé1'], |
|
24 |
['number of rows', '1', '15'], |
|
23 |
['Inner SubCategory', u'sub\xe94', u'sub\xe95', u'sub\xe96', u'sub\xe98', |
|
24 |
u'sub\xe99', u'sub\xe97', u'sub\xe92', u'sub\xe93', u'sub\xe91'], |
|
25 |
['number of rows', '0', '0', '0', '0', '0', '0', '0', '1', '15'] |
|
25 | 26 |
] |
26 | 27 |
form = response.form |
27 | 28 |
form.set('representation', 'table') |
... | ... | |
148 | 149 |
assert get_table(response) == get_ods_table(ods_response)[1:] |
149 | 150 |
root = get_ods_document(ods_response) |
150 | 151 |
nodes = root.findall('.//{%s}table-cell' % TABLE_NS) |
151 |
assert len([node for node in nodes if node.attrib['{%s}value-type' % OFFICE_NS] == 'float']) == 4
|
|
152 |
assert len([node for node in nodes if node.attrib['{%s}value-type' % OFFICE_NS] == 'float']) == 11
|
|
152 | 153 | |
153 | 154 |
app.reset() # logout |
154 | 155 |
assert 'login' in app.get(ods_response.request.url, status=302).location |
155 |
- |