diff --git a/bijoe/engine.py b/bijoe/engine.py index 1b0c5c0..62508a3 100644 --- a/bijoe/engine.py +++ b/bijoe/engine.py @@ -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) diff --git a/tests/test_schema1.py b/tests/test_schema1.py index 706ce35..07ddf47 100644 --- a/tests/test_schema1.py +++ b/tests/test_schema1.py @@ -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('/')