Commit e52f0142 authored by mouadh's avatar mouadh

fix query parsing

parent 783f7d63
...@@ -306,7 +306,7 @@ class MdxEngine: ...@@ -306,7 +306,7 @@ class MdxEngine:
# clean the query (remove All, Members...) # clean the query (remove All, Members...)
return [[ return [[
tup_att.replace('All ', '').replace('[', "").replace("]", "") tup_att.replace('All ', '').replace('[', "").replace("]", "")
for tup_att in tup[0].replace('.Members', '').split('.') for tup_att in tup[0].replace('.Members', '').split('.') if tup_att
] ]
for tup in re.compile(regex).findall( for tup in re.compile(regex).findall(
query.encode("utf-8")[start:stop]) query.encode("utf-8")[start:stop])
......
...@@ -115,32 +115,32 @@ def test_parsing_query2(): ...@@ -115,32 +115,32 @@ def test_parsing_query2():
def test_parsing_query3(): def test_parsing_query3():
query_parts = executer.decorticate_query(query3) query_parts = executer.decorticate_query(query3)
assert query_parts['all'] == [['Geography', 'Geo', 'Country', ''], ['Measures', 'Amount']] assert query_parts['all'] == [['Geography', 'Geo', 'Country'], ['Measures', 'Amount']]
assert query_parts['rows'] == [['Measures', 'Amount']] assert query_parts['rows'] == [['Measures', 'Amount']]
assert query_parts['where'] == [] assert query_parts['where'] == []
assert query_parts['columns'] == [['Geography', 'Geo', 'Country', '']] assert query_parts['columns'] == [['Geography', 'Geo', 'Country']]
query_parts = executer.decorticate_query(query3 + '\n' + where) query_parts = executer.decorticate_query(query3 + '\n' + where)
assert query_parts['all'] == [['Geography', 'Geo', 'Country', ''], ['Measures', 'Amount'], assert query_parts['all'] == [['Geography', 'Geo', 'Country'], ['Measures', 'Amount'],
['Time', 'Calendar', 'Day', 'May 12,2010']] ['Time', 'Calendar', 'Day', 'May 12,2010']]
assert query_parts['rows'] == [['Measures', 'Amount']] assert query_parts['rows'] == [['Measures', 'Amount']]
assert query_parts['where'] == [] assert query_parts['where'] == []
assert query_parts['columns'] == [['Geography', 'Geo', 'Country', '']] assert query_parts['columns'] == [['Geography', 'Geo', 'Country']]
def test_parsing_query4(): def test_parsing_query4():
query_parts = executer.decorticate_query(query4) query_parts = executer.decorticate_query(query4)
assert query_parts['all'] == [['Geography', 'Economy', 'Partnership'], ['Geography', 'Geo', 'Country', '']] assert query_parts['all'] == [['Geography', 'Economy', 'Partnership'], ['Geography', 'Geo', 'Country']]
assert query_parts['rows'] == [['Geography', 'Geo', 'Country', '']] assert query_parts['rows'] == [['Geography', 'Geo', 'Country']]
assert query_parts['where'] == [] assert query_parts['where'] == []
assert query_parts['columns'] == [['Geography', 'Economy', 'Partnership']] assert query_parts['columns'] == [['Geography', 'Economy', 'Partnership']]
query_parts = executer.decorticate_query(query4 + '\n' + where) query_parts = executer.decorticate_query(query4 + '\n' + where)
assert query_parts['all'] == [['Geography', 'Economy', 'Partnership'], ['Geography', 'Geo', 'Country', ''], assert query_parts['all'] == [['Geography', 'Economy', 'Partnership'], ['Geography', 'Geo', 'Country'],
['Time', 'Calendar', 'Day', 'May 12,2010']] ['Time', 'Calendar', 'Day', 'May 12,2010']]
assert query_parts['rows'] == [['Geography', 'Geo', 'Country', '']] assert query_parts['rows'] == [['Geography', 'Geo', 'Country']]
assert query_parts['where'] == [] assert query_parts['where'] == []
assert query_parts['columns'] == [['Geography', 'Economy', 'Partnership']] assert query_parts['columns'] == [['Geography', 'Economy', 'Partnership']]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment