Combine all top-level filters into a single filter (with operator "and").

This commit is contained in:
Gunnar Beutner 2013-03-10 15:23:08 +01:00
parent 79579e9bb1
commit dc27ddaada
2 changed files with 10 additions and 11 deletions

View File

@ -116,7 +116,14 @@ Query::Query(const vector<String>& lines)
} }
} }
m_Filters.swap(filters); /* Combine all top-level filters into a single filter. */
AndFilter::Ptr top_filter = boost::make_shared<AndFilter>();
BOOST_FOREACH(const Filter::Ptr& filter, filters) {
top_filter->AddSubFilter(filter);
}
m_Filter = top_filter;
m_Stats.swap(stats); m_Stats.swap(stats);
} }
@ -172,15 +179,7 @@ void Query::ExecuteGetHelper(const Stream::Ptr& stream)
return; return;
} }
if (m_Filters.size() > 1) vector<Object::Ptr> objects = table->FilterRows(m_Filter);
SendResponse(stream, 452, "There must not be more than one top-level filter expression.");
Filter::Ptr filter;
if (!m_Filters.empty())
filter = m_Filters[0];
vector<Object::Ptr> objects = table->FilterRows(filter);
vector<String> columns; vector<String> columns;
if (m_Columns.size() > 0) if (m_Columns.size() > 0)

View File

@ -45,7 +45,7 @@ private:
String m_Table; String m_Table;
vector<String> m_Columns; vector<String> m_Columns;
deque<Filter::Ptr> m_Filters; Filter::Ptr m_Filter;
deque<Filter::Ptr> m_Stats; deque<Filter::Ptr> m_Stats;
String m_OutputFormat; String m_OutputFormat;