This is an automated email from the ASF dual-hosted git repository.
willholley pushed a commit to branch mango-beginswith
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/mango-beginswith by this push:
new e0c1ab6f2 address PR comments
e0c1ab6f2 is described below
commit e0c1ab6f2420582b9650f6ef2f73aa71c58b825a
Author: Will Holley <[email protected]>
AuthorDate: Mon Oct 30 09:07:19 2023 +0000
address PR comments
---
src/docs/src/api/database/find.rst | 12 +++++++-----
src/mango/test/03-operator-test.py | 6 +++++-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/docs/src/api/database/find.rst
b/src/docs/src/api/database/find.rst
index e94326b53..63665ae35 100644
--- a/src/docs/src/api/database/find.rst
+++ b/src/docs/src/api/database/find.rst
@@ -200,8 +200,9 @@ A simple selector, inspecting specific fields:
You can create more complex selector expressions by combining operators.
For best performance, it is best to combine 'combination' or
-'array logical' operators, such as ``$regex``, with an equality
-operators such as ``$eq``, ``$gt``, ``$gte``, ``$lt``, and ``$lte``
+'array logical' operators, such as ``$regex``, with an operator
+that defines a contiguous range of keys such as ``$eq``,
+``$gt``, ``$gte``, ``$lt``, ``$lte``, and ``$beginsWith``
(but not ``$ne``). For more information about creating complex
selector expressions, see :ref:`creating selector expressions
<find/expressions>`.
@@ -759,11 +760,12 @@ In general, whenever you have an operator that takes an
argument, that argument
can itself be another operator with arguments of its own. This enables us to
build up more complex selector expressions.
-However, only equality operators such as ``$eq``, ``$gt``, ``$gte``, ``$lt``,
-``$lte`` and ``$beginsWith`` (but not ``$ne``) can be used as the basis
+However, only operators that define a contiguous range of values
+such as ``$eq``, ``$gt``, ``$gte``, ``$lt``, ``$lte``,
+and ``$beginsWith`` (but not ``$ne``) can be used as the basis
of a query that can make efficient use of a ``json`` index. You should
include at least one of these in a selector, or consider using
-a ``text`` index if more flexibility is required.
+a ``text`` index if greater flexibility is required.
For example, if you try to perform a query that attempts to match all documents
that have a field called `afieldname` containing a value that begins with the
diff --git a/src/mango/test/03-operator-test.py
b/src/mango/test/03-operator-test.py
index 8d216d9d8..3d4503b4f 100644
--- a/src/mango/test/03-operator-test.py
+++ b/src/mango/test/03-operator-test.py
@@ -171,8 +171,12 @@ class BaseOperatorTests:
cases = [123, True, [], {}]
for prefix in cases:
with self.subTest(prefix=prefix):
- with self.assertRaises(HTTPError):
+ try:
self.db.find({"location.state": {"$beginsWith":
prefix}})
+ except Exception as e:
+ self.assertEqual(e.response.status_code, 400)
+ else:
+ raise AssertionError("expected request to fail")
class OperatorJSONTests(mango.UserDocsTests, BaseOperatorTests.Common):