Skip to content

Commit b7ecc39

Browse files
author
root
committed
fix 'filter with empty name' error
1 parent 080525d commit b7ecc39

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/searchdsql.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,8 +1806,18 @@ bool SqlParser_c::AddNullFilter ( const SqlNode_t & tCol, bool bEqualsNull )
18061806

18071807
void SqlParser_c::AddHaving ()
18081808
{
1809-
assert ( m_pQuery->m_dFilters.GetLength() );
1810-
m_pQuery->m_tHaving = m_pQuery->m_dFilters.Pop();
1809+
// Move the last parsed filter into HAVING
1810+
assert ( m_pQuery->m_dFilters.GetLength() );
1811+
m_pQuery->m_tHaving = m_pQuery->m_dFilters.Pop();
1812+
1813+
// FIX(#887): The filter tree (m_dFilterTree) still contains a leaf for the
1814+
// just-moved HAVING predicate. If we keep it, CreateFilterTree() for WHERE
1815+
// will attempt to build a node for a filter that was popped <E2><86><92> it will look
1816+
// like a filter with an empty name and throw "filter with empty name".
1817+
//
1818+
// Remove the trailing tree op that corresponds to the just-added HAVING item.
1819+
if ( m_dFilterTree.GetLength() > 0 )
1820+
m_dFilterTree.Pop();
18111821
}
18121822

18131823

0 commit comments

Comments
 (0)