Projet

Général

Profil

0001-engine-fix-filtering-of-members-of-unjoined-dimensio.patch

Benjamin Dauvergne, 20 juin 2020 00:20

Télécharger (2,23 ko)

Voir les différences:

Subject: [PATCH] engine: fix filtering of members of unjoined dimensions
 (#44289)

 bijoe/engine.py       | 7 +++----
 tests/test_schema1.py | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)
bijoe/engine.py
163 163
        conditions = []
164 164
        for dimension_name, values in filters:
165 165
            dimension = self.engine_cube.dimensions[dimension_name]
166
            if not (set(dimension.join or []) & set(self.join or [])):
166
            if dimension_name != self.name and not (set(dimension.join or []) & set(self.join or [])):
167 167
                continue
168 168
            # assert dimension.filter
169 169
            condition, values = dimension.build_filter(values)
......
171 171
                continue
172 172
            with self.engine.get_cursor() as cursor:  # Ugly...
173 173
                condition = force_text(cursor.mogrify(condition, values))
174
            if dimension.filter_needs_join and dimension.join:
175
                joins.update(dimension.join)
176 174
            conditions.append(condition)
177
            joins.update(dimension.join)
175
            if dimension.join:
176
                joins.update(dimension.join)
178 177

  
179 178
        with self.engine.get_cursor() as cursor:
180 179
            sql = self.members_query
tests/test_schema1.py
95 95
    assert get_table(response) == [['String', 'a', 'b', 'c', 'Aucun(e)'], ['number of rows', '11', '2', '3', '1']]
96 96
    form.set('filter__string', ['a', 'b', '__none__'])
97 97
    response = form.submit('visualize')
98
    assert get_table(response) == [['String', 'a', 'b', 'c', 'Aucun(e)'], ['number of rows', '11', '2', '0', '1']]
98
    assert get_table(response) == [['String', 'a', 'b', 'Aucun(e)'], ['number of rows', '11', '2', '1']]
99 99

  
100 100

  
101 101
def test_string_dimension_json_data(schema1, app, admin):
102
-