unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* WIP: fixes for implicit operators and subqueries
@ 2019-09-01  1:37 David Bremner
  2019-09-01  1:37 ` [WIP2 1/5] lib: rename _debug_query to _notmuch_query_debug, make extern David Bremner
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: David Bremner @ 2019-09-01  1:37 UTC (permalink / raw)
  To: notmuch

This obsoletes the patches discussed at

     id:871rx38q8y.fsf@tethera.net

and

     id:20190821114126.23540-2-david@tethera.net

I think I still have a spelling error in the commit message that Tomi
caught, and I need to update notmuch-search-terms(7). Before I do
that, please have a look at the new tests and see if the expected
behaviour in the tests makes sense.

We still won't have working subqueries for boolean fields,
reasons discussed in

    https://trac.xapian.org/ticket/795
    
field:"(foo bar)" does not currently work for e.g. tag: or id:

There is also the unfortunate aspect that non-regex supporting fields
like "to" support Xapian to:(david tethera), but regex supporting
fields need from:"(david tethera)". It's not obvious how to fix this
without radically changing the regex syntax (e.g. to use distinct
prefixes rather than //), and I think that would annoy more people
than the quirky subquery quoting.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [WIP2 1/5] lib: rename _debug_query to _notmuch_query_debug, make extern
  2019-09-01  1:37 WIP: fixes for implicit operators and subqueries David Bremner
@ 2019-09-01  1:37 ` David Bremner
  2019-09-01  1:37 ` [WIP2 2/5] test: add known broken tests for implicit operators David Bremner
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2019-09-01  1:37 UTC (permalink / raw)
  To: notmuch

This makes it available for use within the field processors.
---
 lib/notmuch-private.h |  5 +++++
 lib/query.cc          | 10 +++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 9bdb68ab..f0657147 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -519,6 +519,11 @@ void
 _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids,
 			    unsigned int doc_id);
 
+/* utility function to control debugging output */
+
+bool
+_notmuch_query_debug ();
+
 /* querying xapian documents by type (e.g. "mail" or "ghost"): */
 notmuch_status_t
 _notmuch_query_search_documents (notmuch_query_t *query,
diff --git a/lib/query.cc b/lib/query.cc
index 792aba21..7b815dc5 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -67,8 +67,8 @@ _notmuch_doc_id_set_init (void *ctx,
 			  notmuch_doc_id_set_t *doc_ids,
 			  GArray *arr);
 
-static bool
-_debug_query (void)
+bool
+_notmuch_query_debug (void)
 {
     char *env = getenv ("NOTMUCH_DEBUG_QUERY");
 
@@ -90,7 +90,7 @@ notmuch_query_create (notmuch_database_t *notmuch,
 {
     notmuch_query_t *query;
 
-    if (_debug_query ())
+    if (_notmuch_query_debug ())
 	fprintf (stderr, "Query string is:\n%s\n", query_string);
 
     query = talloc (notmuch, notmuch_query_t);
@@ -334,7 +334,7 @@ _notmuch_query_search_documents (notmuch_query_t *query,
 	    break;
 	}
 
-	if (_debug_query ()) {
+	if (_notmuch_query_debug ()) {
 	    fprintf (stderr, "Exclude query is:\n%s\n",
 		     exclude_query.get_description ().c_str ());
 	    fprintf (stderr, "Final query is:\n%s\n",
@@ -638,7 +638,7 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign
 	enquire.set_weighting_scheme (Xapian::BoolWeight ());
 	enquire.set_docid_order (Xapian::Enquire::ASCENDING);
 
-	if (_debug_query ()) {
+	if (_notmuch_query_debug ()) {
 	    fprintf (stderr, "Exclude query is:\n%s\n",
 		     exclude_query.get_description ().c_str ());
 	    fprintf (stderr, "Final query is:\n%s\n",
-- 
2.23.0.rc1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [WIP2 2/5] test: add known broken tests for implicit operators
  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 ` David Bremner
  2019-09-01  1:37 ` [WIP2 3/5] lib: introduce N_F_GROUP and use it to fix implicit AND for from: David Bremner
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2019-09-01  1:37 UTC (permalink / raw)
  To: notmuch

Given we want 'a b' to parse as 'a AND b', then for any
probabilistic (free text) prefix foo:, we should also get 'foo:a
foo:b' expanding to 'foo:a AND foo:b'. Currently this is not true due
to the implimentation of regex fields. On the other hand for
"exclusive" (i.e. one per message) fields, we want the 'foo:a foo:b'
to expand to (foo:a OR foo:b) since otherwise it will be empty unless
a=b.  The regex variants complicate things, but we stick to the same
rules.

Some of these tests pass, when we are following the Xapian defaults,
and not trying to tricky things with boolean fields impersonating
probabilistic ones.
---
 test/T760-implicit-operators.sh | 161 ++++++++++++++++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100755 test/T760-implicit-operators.sh

diff --git a/test/T760-implicit-operators.sh b/test/T760-implicit-operators.sh
new file mode 100755
index 00000000..40f0bc22
--- /dev/null
+++ b/test/T760-implicit-operators.sh
@@ -0,0 +1,161 @@
+#!/usr/bin/env bash
+test_description='implicit operators in query parser'
+. $(dirname "$0")/test-lib.sh || exit 1
+
+# test expected behaviour for probabilistic fields
+
+test_prob() {
+    add_message  "[id]=$1@one [$1]='Alice <agent@tla.galactic.over.lord>'"
+    add_message  "[id]=$1@two [$1]='Bob <bungler@tla.galactic.over.lord>'"
+
+    test_begin_subtest "phrase search for '$1': matches"
+    notmuch search --output=messages id:$1@one > EXPECTED
+    notmuch search --output=messages "$1:\"alice agent\"" > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+
+    test_begin_subtest "out of order phrase '$1': does not match"
+    notmuch search --output=messages "$1:\"agent alice\"" > OUTPUT
+    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
+}
+
+# test expected behaviour for probabilistic fields that also support
+# regex search
+
+test_prob_regex() {
+    test_prob $1 $2
+
+    test_begin_subtest "regex for '$1': matches"
+    notmuch search --output=messages id:$1@one > EXPECTED
+    notmuch search --output=messages "$1:/agent@tla/" > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+
+    test_begin_subtest "regex wrong punctation for '$1': does not"
+    notmuch search --output=messages "$1:/agent-tla/" > OUTPUT
+    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
+
+    test_begin_subtest "subquery for '$1' implicit AND"
+    $2
+    notmuch search --output=messages id:$1@one > EXPECTED
+    notmuch search --output=messages "$1:\"(agent alice)\"" > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+}
+
+
+# we have to test this separately because the quoting is sadly different
+test_prob_not_regex() {
+    test_prob $1
+
+    test_begin_subtest "subquery for '$1' implicit AND"
+    notmuch search --output=messages id:$1@one > EXPECTED
+    notmuch search --output=messages "$1:(agent alice)" > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+}
+
+test_bool_exclusive () {
+    add_message "[id]=$1@one [$2]=$1@one"
+    add_message "[id]=$1@two [$2]=$1@two"
+
+    test_begin_subtest "'$1' implicit OR"
+    notmuch search --output=messages $1:$1@one OR $1:$1@two > EXPECTED
+    notmuch search --output=messages $1:$1@one $1:$1@two > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+}
+
+test_bool_exclusive_regex () {
+    test_bool_exclusive $1 $2
+
+    test_begin_subtest "regex '$1' implicit OR"
+    notmuch search --output=messages $1:$1@one OR $1:$1@two > EXPECTED
+    notmuch search --output=messages $1:/^$1@one/ $1:/^$1@two/ > OUTPUT
+    test_expect_equal_file EXPECTED OUTPUT
+}
+
+add_email_corpus
+
+test_prob_not_regex to
+test_prob_not_regex body
+test_prob_regex from test_subtest_known_broken
+test_prob_regex subject test_subtest_known_broken
+
+test_bool_exclusive id id
+test_bool_exclusive_regex mid id
+test_bool_exclusive_regex path dir
+test_bool_exclusive folder dir
+
+add_message "[id]=aug@2019 [date]='Sat, 31 Aug 2019 01:14:40 -0400'"
+add_message "[id]=may@2014 [date]='Thu, 22 May 2014 11:45:01 -0700'"
+test_begin_subtest "'date' is implicit OR"
+notmuch search --output=messages date:2019 OR date:2014 > EXPECTED
+notmuch search --output=messages date:2019 date:2014 > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+add_message "[id]=tag@one"
+add_message "[id]=tag@two"
+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
+
+test_begin_subtest "'thread:<thread-id>' is implicit OR"
+notmuch search --output=messages thread:0000000000000001 OR thread:0000000000000002 > EXPECTED
+notmuch search --output=messages thread:0000000000000001 thread:0000000000000002 > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "sanity check for non-zero output"
+test_expect_success "test -s OUTPUT"
+
+test_begin_subtest "'mimetype' is implicit AND"
+notmuch search --output=messages mimetype:application/pgp-signature AND \
+        mimetype:multipart/signed > EXPECTED
+notmuch search --output=messages mimetype:application/pgp-signature \
+        mimetype:multipart/signed > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "sanity check for non-zero output"
+test_expect_success "test -s OUTPUT"
+
+test_begin_subtest "'mimetype' is implicit AND (II)"
+notmuch search --output=messages is:signed > EXPECTED
+notmuch search --output=messages mimetype:application/pgp-signature  mimetype:multipart/signed > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "'attachment' with OR is non-empty"
+notmuch search --output=messages attachment:notmuch-help.patch \
+        OR attachment:signature.asc > OUTPUT
+test_expect_success "test -s OUTPUT"
+
+test_begin_subtest "'attachment' is implicit AND"
+notmuch search --output=messages attachment:notmuch-help.patch AND \
+        attachment:signature.asc > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_begin_subtest "'folder' with OR is non-empty"
+notmuch search --output=messages folder:bar/baz \
+        folder:foo/baz > OUTPUT
+test_expect_success "test -s OUTPUT"
+
+test_begin_subtest "'folder' is implicit AND"
+notmuch search --output=messages folder:bar/baz \
+        attachment:signature.asc > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_begin_subtest "'lastmod' is implicit OR"
+notmuch search lastmod:0..1 lastmod:2..1000 > OUTPUT
+test_expect_success "test -s OUTPUT"
+
+test_done
-- 
2.23.0.rc1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [WIP2 3/5] lib: introduce N_F_GROUP and use it to fix implicit AND for from:
  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
  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
  4 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2019-09-01  1:37 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [WIP2 4/5] test: add known broken tests for parenthesized subqueries
  2019-09-01  1:37 WIP: fixes for implicit operators and subqueries David Bremner
                   ` (2 preceding siblings ...)
  2019-09-01  1:37 ` [WIP2 3/5] lib: introduce N_F_GROUP and use it to fix implicit AND for from: David Bremner
@ 2019-09-01  1:37 ` David Bremner
  2019-09-01  1:37 ` [WIP2 5/5] lib: special case parenthesized subqueries in regex fields David Bremner
  4 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2019-09-01  1:37 UTC (permalink / raw)
  To: notmuch

The quoting around the () is needed because of our choice of using
boolean fields at the Xapian level, and [1]

[1]: https://trac.xapian.org/ticket/795
---
 test/T650-regexp-query.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/T650-regexp-query.sh b/test/T650-regexp-query.sh
index 43af3b47..05a04791 100755
--- a/test/T650-regexp-query.sh
+++ b/test/T650-regexp-query.sh
@@ -182,4 +182,28 @@ notmuch search tag:signed > EXPECTED
 notmuch search tag:/^si/ > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "parenthesized subqueries are not phrases"
+test_subtest_known_broken
+notmuch search subject:notmuch AND subject:outputs > EXPECTED
+notmuch search 'subject:"(notmuch outputs)"' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "parenthesized subqueries work with OR"
+test_subtest_known_broken
+notmuch search subject:notmuch OR subject:outputs > EXPECTED
+notmuch search 'subject:"(notmuch OR outputs)"' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "parenthesized subqueries work with AND"
+test_subtest_known_broken
+notmuch search subject:notmuch AND subject:outputs > EXPECTED
+notmuch search 'subject:"(notmuch AND outputs)"' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "parenthesized subqueries work with overidden prefix"
+test_subtest_known_broken
+notmuch search subject:help AND subject:outputs AND to:notmuch > EXPECTED
+notmuch search 'subject:"(outputs help to:notmuch)"' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.23.0.rc1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [WIP2 5/5] lib: special case parenthesized subqueries in regex fields
  2019-09-01  1:37 WIP: fixes for implicit operators and subqueries David Bremner
                   ` (3 preceding siblings ...)
  2019-09-01  1:37 ` [WIP2 4/5] test: add known broken tests for parenthesized subqueries David Bremner
@ 2019-09-01  1:37 ` David Bremner
  4 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2019-09-01  1:37 UTC (permalink / raw)
  To: notmuch

These should not be treated as phrase searches. Due to the problem
outlined in [1] it is not possible to use a query string

         subject:(foo bar)

but at least with this fix

         subject:"(foo bar)"

expands to subject:foo OP subject:bar, which is more useful than
another way to type a phrase search.

[1]: https://trac.xapian.org/ticket/795
---
 lib/regexp-fields.cc            | 19 +++++++++++++++++++
 test/T650-regexp-query.sh       |  4 ----
 test/T760-implicit-operators.sh |  7 +++----
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 198eb32f..3f92b2ab 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -189,6 +189,25 @@ RegexpFieldProcessor::operator() (const std::string & str)
 	} else {
 	    throw Xapian::QueryParserError ("unmatched regex delimiter in '" + str + "'");
 	}
+    }	else if (str.at (0) == '(') {
+	if (str.length () > 1 && str.at (str.size () - 1) == ')') {
+	    std::string subexp_str = str.substr (1, str.size () - 2);
+	    Xapian::Query query = parser.parse_query (subexp_str,
+						      NOTMUCH_QUERY_PARSER_FLAGS,
+						      term_prefix);
+
+	    if (_notmuch_query_debug ()) {
+		fprintf (stderr, "subquery string [prefix=%s]:\n%s\n",
+			 term_prefix.c_str (),
+			 subexp_str.c_str ());
+		fprintf (stderr, "parsed subquery:\n%s\n",
+		     query.get_description ().c_str ());
+	    }
+
+	    return query;
+	} else {
+	    throw Xapian::QueryParserError ("unmatched '(' in '" + str + "'");
+	}
     } else {
 	if (options & NOTMUCH_FIELD_PROBABILISTIC) {
 	    /* TODO replace this with a nicer API level triggering of
diff --git a/test/T650-regexp-query.sh b/test/T650-regexp-query.sh
index 05a04791..d9ffd2e7 100755
--- a/test/T650-regexp-query.sh
+++ b/test/T650-regexp-query.sh
@@ -183,25 +183,21 @@ notmuch search tag:/^si/ > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "parenthesized subqueries are not phrases"
-test_subtest_known_broken
 notmuch search subject:notmuch AND subject:outputs > EXPECTED
 notmuch search 'subject:"(notmuch outputs)"' > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "parenthesized subqueries work with OR"
-test_subtest_known_broken
 notmuch search subject:notmuch OR subject:outputs > EXPECTED
 notmuch search 'subject:"(notmuch OR outputs)"' > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "parenthesized subqueries work with AND"
-test_subtest_known_broken
 notmuch search subject:notmuch AND subject:outputs > EXPECTED
 notmuch search 'subject:"(notmuch AND outputs)"' > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "parenthesized subqueries work with overidden prefix"
-test_subtest_known_broken
 notmuch search subject:help AND subject:outputs AND to:notmuch > EXPECTED
 notmuch search 'subject:"(outputs help to:notmuch)"' > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
diff --git a/test/T760-implicit-operators.sh b/test/T760-implicit-operators.sh
index 118a9de2..1eab4ec9 100755
--- a/test/T760-implicit-operators.sh
+++ b/test/T760-implicit-operators.sh
@@ -27,7 +27,7 @@ test_prob() {
 # regex search
 
 test_prob_regex() {
-    test_prob $1 $2
+    test_prob $1
 
     test_begin_subtest "regex for '$1': matches"
     notmuch search --output=messages id:$1@one > EXPECTED
@@ -44,7 +44,6 @@ test_prob_regex() {
     test_expect_equal_file EXPECTED OUTPUT
 
     test_begin_subtest "subquery for '$1' implicit AND"
-    $2
     notmuch search --output=messages id:$1@one > EXPECTED
     notmuch search --output=messages "$1:\"(agent alice)\"" > OUTPUT
     test_expect_equal_file EXPECTED OUTPUT
@@ -84,8 +83,8 @@ add_email_corpus
 
 test_prob_not_regex to
 test_prob_not_regex body
-test_prob_regex from test_subtest_known_broken
-test_prob_regex subject test_subtest_known_broken
+test_prob_regex from
+test_prob_regex subject
 
 test_bool_exclusive id id
 test_bool_exclusive_regex mid id
-- 
2.23.0.rc1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-01  1:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [WIP2 3/5] lib: introduce N_F_GROUP and use it to fix implicit AND for from: David Bremner
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

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).