engine: format where sql condition string (#47766)

This commit is contained in:
Nicolas Roche 2020-11-06 12:27:54 +01:00
parent cac1bc1534
commit 0ad3cc58ae
2 changed files with 28 additions and 0 deletions

View File

@ -421,6 +421,7 @@ class EngineCube(object):
where_conditions = 'true'
if where:
where_conditions = ' AND '.join(where)
where_conditions = where_conditions.format(fact_table=self.cube.fact_table)
sql += ' WHERE %s' % where_conditions
if group_by:
sql += ' GROUP BY %s' % ', '.join(group_by)

View File

@ -378,6 +378,33 @@ def test_json_dimensions(schema1, app, admin):
]
def test_json_dimensions_having_percent(schema1, app, admin):
login(app, admin)
response = app.get('/')
response = response.click('schema1')
response = response.click('Facts 1')
form = response.form
form.set('representation', 'table')
form.set('measure', 'percent')
form.set('drilldown_x', 'a')
response = form.submit('visualize')
assert get_table(response) == [
['A', 'x', 'y', 'z'],
['pourcentage des demandes', '41,18 %', '52,94 %', '5,88 %']
]
assert 'filter__a' in form.fields
assert set([o[0] for o in form['filter__a'].options]) == {'x', 'y', 'z', '__none__'}
form.set('filter__a', ['x', 'y'])
response = form.submit('visualize')
assert get_table(response) == [
['A', 'x', 'y', 'z'],
['pourcentage des demandes', '43,75 %', '56,25 %', '0,00 %']
]
def test_sum_integer_measure(schema1, app, admin):
login(app, admin)
response = app.get('/')