[PATCH 2/3] lib: introduce N_F_GROUP and use it to fix implicit AND for from:

David Bremner david at tethera.net
Wed Aug 21 04:41:25 PDT 2019


This needs tests for every prefix and documentation
---
 lib/database-private.h          |  1 +
 lib/database.cc                 | 23 +++++++++++++++++------
 test/T760-implicit-operators.sh |  4 ++--
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/lib/database-private.h b/lib/database-private.h
index 87ae1bdf..a5eb83cb 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -159,6 +159,7 @@ typedef enum notmuch_field_flags {
     NOTMUCH_FIELD_EXTERNAL	= 1 << 0,
     NOTMUCH_FIELD_PROBABILISTIC = 1 << 1,
     NOTMUCH_FIELD_PROCESSOR	= 1 << 2,
+    NOTMUCH_FIELD_GROUP		= 1 << 3,
 } notmuch_field_flag_t;
 
 /*
diff --git a/lib/database.cc b/lib/database.cc
index 24b7ec43..5d6c4ee6 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -272,16 +272,21 @@ prefix_t prefix_table[] = {
     { "body",                   "",             NOTMUCH_FIELD_EXTERNAL |
       NOTMUCH_FIELD_PROBABILISTIC },
     { "thread",                 "G",            NOTMUCH_FIELD_EXTERNAL |
-      NOTMUCH_FIELD_PROCESSOR },
+      NOTMUCH_FIELD_PROCESSOR |
+      NOTMUCH_FIELD_GROUP
+    },
     { "tag",                    "K",            NOTMUCH_FIELD_EXTERNAL |
       NOTMUCH_FIELD_PROCESSOR },
     { "is",                     "K",            NOTMUCH_FIELD_EXTERNAL |
       NOTMUCH_FIELD_PROCESSOR },
-    { "id",                     "Q",            NOTMUCH_FIELD_EXTERNAL },
+    { "id",                     "Q",            NOTMUCH_FIELD_EXTERNAL |
+      NOTMUCH_FIELD_GROUP },
     { "mid",                    "Q",            NOTMUCH_FIELD_EXTERNAL |
       NOTMUCH_FIELD_PROCESSOR },
     { "path",                   "P",            NOTMUCH_FIELD_EXTERNAL |
-      NOTMUCH_FIELD_PROCESSOR },
+      NOTMUCH_FIELD_PROCESSOR |
+      NOTMUCH_FIELD_GROUP
+    },
     { "property",               "XPROPERTY",    NOTMUCH_FIELD_EXTERNAL },
     /*
      * Unconditionally add ':' to reduce potential ambiguity with
@@ -290,10 +295,14 @@ prefix_t prefix_table[] = {
      * discussion.
      */
     { "folder",                 "XFOLDER:",     NOTMUCH_FIELD_EXTERNAL |
-      NOTMUCH_FIELD_PROCESSOR },
+      NOTMUCH_FIELD_PROCESSOR |
+      NOTMUCH_FIELD_GROUP
+    },
 #if HAVE_XAPIAN_FIELD_PROCESSOR
     { "date",                   NULL,           NOTMUCH_FIELD_EXTERNAL |
-      NOTMUCH_FIELD_PROCESSOR },
+      NOTMUCH_FIELD_PROCESSOR |
+      NOTMUCH_FIELD_GROUP
+    },
     { "query",                  NULL,           NOTMUCH_FIELD_EXTERNAL |
       NOTMUCH_FIELD_PROCESSOR },
 #endif
@@ -400,7 +409,9 @@ _setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch)
 	/* we treat all field-processor fields as boolean in order to get the raw input */
 	if (prefix->prefix)
 	    notmuch->query_parser->add_prefix ("", prefix->prefix);
-	notmuch->query_parser->add_boolean_prefix (prefix->name, fp);
+	notmuch->query_parser->add_boolean_prefix (prefix->name, fp,
+						   !(prefix->flags & NOTMUCH_FIELD_PROBABILISTIC) &&
+						   (prefix->flags & NOTMUCH_FIELD_GROUP));
     } else {
 	_setup_query_field_default (prefix, notmuch);
     }
diff --git a/test/T760-implicit-operators.sh b/test/T760-implicit-operators.sh
index b79673df..1a6ba61f 100755
--- a/test/T760-implicit-operators.sh
+++ b/test/T760-implicit-operators.sh
@@ -21,8 +21,8 @@ EOF
     test_expect_equal_file EXPECTED OUTPUT
 }
 
-test_AND from test_subtest_known_broken
-test_AND subject test_subtest_known_broken
+test_AND from
+test_AND subject
 test_AND to
 
 test_done
-- 
2.23.0.rc1



More information about the notmuch mailing list