unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [WIP2 3/5] lib: introduce N_F_GROUP and use it to fix implicit AND for from:
Date: Sat, 31 Aug 2019 22:37:46 -0300	[thread overview]
Message-ID: <20190901013748.7470-4-david@tethera.net> (raw)
In-Reply-To: <20190901013748.7470-1-david@tethera.net>

We try to match the rules discussed in the last commit: probabilistic
fields are implicit AND, and boolean fields are implicit OR, unless
they can be repeated (tag: being the prominent example of a
repeating, i.e. non-exclusive field).
---
 lib/database-private.h          |  1 +
 lib/database.cc                 | 27 ++++++++++++++++++++-------
 test/T760-implicit-operators.sh |  3 ---
 3 files changed, 21 insertions(+), 10 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..4148df5a 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -272,16 +272,23 @@ 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 },
+      NOTMUCH_FIELD_PROCESSOR |
+      NOTMUCH_FIELD_GROUP
+    },
     { "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 +297,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 +411,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 40f0bc22..118a9de2 100755
--- a/test/T760-implicit-operators.sh
+++ b/test/T760-implicit-operators.sh
@@ -18,7 +18,6 @@ test_prob() {
     test_expect_equal_file /dev/null OUTPUT
 
     test_begin_subtest "field '$1' is implicit AND"
-    $2
     notmuch search $1:agent and $1:tla > EXPECTED
     notmuch search $1:agent $1:tla > OUTPUT
     test_expect_equal_file EXPECTED OUTPUT
@@ -40,7 +39,6 @@ test_prob_regex() {
     test_expect_equal_file /dev/null OUTPUT
 
     test_begin_subtest "regex for '$1' implicit AND"
-    $2
     notmuch search --output=messages id:$1@one > EXPECTED
     notmuch search --output=messages $1:/agent/ $1:/tla/ > OUTPUT
     test_expect_equal_file EXPECTED OUTPUT
@@ -107,7 +105,6 @@ notmuch tag +one id:tag@one
 notmuch tag +two id:tag@two
 
 test_begin_subtest "'tag' is implicit AND"
-test_subtest_known_broken
 notmuch search --output=messages tag:one tag:two > OUTPUT
 test_expect_equal_file /dev/null OUTPUT
 
-- 
2.23.0.rc1

  parent reply	other threads:[~2019-09-01  1:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-01  1:37 WIP: fixes for implicit operators and subqueries David Bremner
2019-09-01  1:37 ` [WIP2 1/5] lib: rename _debug_query to _notmuch_query_debug, make extern David Bremner
2019-09-01  1:37 ` [WIP2 2/5] test: add known broken tests for implicit operators David Bremner
2019-09-01  1:37 ` David Bremner [this message]
2019-09-01  1:37 ` [WIP2 4/5] test: add known broken tests for parenthesized subqueries David Bremner
2019-09-01  1:37 ` [WIP2 5/5] lib: special case parenthesized subqueries in regex fields David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190901013748.7470-4-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).