r19130 - gnucash/trunk/src/libqof/qof - A search with no search terms set by the user should still honor the original search constraints.

Geert Janssens gjanssens at code.gnucash.org
Thu May 6 12:23:10 EDT 2010


Author: gjanssens
Date: 2010-05-06 12:23:10 -0400 (Thu, 06 May 2010)
New Revision: 19130
Trac: http://svn.gnucash.org/trac/changeset/19130

Modified:
   gnucash/trunk/src/libqof/qof/qofquery.c
Log:
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.

Modified: gnucash/trunk/src/libqof/qof/qofquery.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofquery.c	2010-05-06 15:15:36 UTC (rev 19129)
+++ gnucash/trunk/src/libqof/qof/qofquery.c	2010-05-06 16:23:10 UTC (rev 19130)
@@ -1109,7 +1109,7 @@
     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 @@
      * 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;
     }



More information about the gnucash-changes mailing list