Commit f69ffe01 authored by Tomaž Jerman's avatar Tomaž Jerman
Browse files

Fix filter nesting for chart filters

parent 2b3b2f17
......@@ -150,7 +150,11 @@ func (b *recordReportBuilder) Build(metrics, dimensions, filters string) (sql st
return
}
b.report = b.report.Where(filter)
// We need to wrap this one level deeper, since additional filters should
// be evaluated as a whole.
// For example A AND B OR C =should be> (A AND B OR C)
// so the output becomes BASE AND (ADDITIONAL)
b.report = b.report.Where(ql.ASTNodes{filter})
}
return b.report.ToSql()
......
......@@ -24,7 +24,7 @@ func TestRecordReportBuilder2(t *testing.T) {
"FROM compose_record AS r " +
"LEFT JOIN compose_record_value AS rv_single1 ON (rv_single1.record_id = r.id AND rv_single1.name = ? AND rv_single1.deleted_at IS NULL) " +
"LEFT JOIN compose_record_value AS rv_ref1 ON (rv_ref1.record_id = r.id AND rv_ref1.name = ? AND rv_ref1.deleted_at IS NULL) " +
"WHERE r.deleted_at IS NULL AND r.module_id = ? AND rv_ref1.value = 2 " +
"WHERE r.deleted_at IS NULL AND r.module_id = ? AND (rv_ref1.value = 2) " +
"GROUP BY dimension_0 " +
"ORDER BY dimension_0"
......
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