From a83c3f73f6eeff57e5a690b15152304ef875b853 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 6 May 2010 16:23:10 +0000 Subject: [PATCH] A search with no search terms set by the user should still honor the original search constraints. For example: if a user does: - Find customer - Click on Customer's invoices - Then explicitly removes the empty search term - Click Find => the user should still see only the invoices for this customer. Previously this scenario would return all bills, invoices AND vouchers in the book. The cause was an attempt to merge two queries with AND while one query had no terms. The code already partially checked for this, but there was still an unhandled case. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19130 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/libqof/qof/qofquery.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libqof/qof/qofquery.c b/src/libqof/qof/qofquery.c index 2d7f4385e1..0974aa256d 100644 --- a/src/libqof/qof/qofquery.c +++ b/src/libqof/qof/qofquery.c @@ -1109,7 +1109,7 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op) search_for = (q1->search_for ? q1->search_for : q2->search_for); /* Avoid merge surprises if op==QOF_QUERY_AND but q1 is empty. - * The goal of this tweak is to all the user to start with + * The goal of this tweak is to allow the user to start with * an empty q1 and then append to it recursively * (and q1 (and q2 (and q3 (and q4 ....)))) * without bombing out because the append started with an @@ -1117,7 +1117,8 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op) * We do essentially the same check in qof_query_add_term() * so that the first term added to an empty query doesn't screw up. */ - if ((QOF_QUERY_AND == op) && (0 == qof_query_has_terms (q1))) + if ((QOF_QUERY_AND == op) && + ( (0 == qof_query_has_terms (q1)) || (0 == qof_query_has_terms (q2)) )) { op = QOF_QUERY_OR; }