Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
willholley committed Oct 30, 2023
1 parent a5af777 commit 8e29e60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/docs/src/api/database/find.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/mango/test/03-operator-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ def test_beginswith_invalid_prefix(self):
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):
Expand Down

0 comments on commit 8e29e60

Please sign in to comment.