You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/01/19 19:09:05 UTC

[couchdb] branch 3.2.2-docs updated: docs(mango): match description of `$mod` with reality

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch 3.2.2-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/3.2.2-docs by this push:
     new ef63fdc53 docs(mango): match description of `$mod` with reality
ef63fdc53 is described below

commit ef63fdc533076c6f99ead829dd93c06d639b7833
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Tue Jan 17 10:54:19 2023 +0100

    docs(mango): match description of `$mod` with reality
    
    The remainder argument for the `$mod` operator can be zero, while
    its documentation suggests otherwise.  It actually covers a very
    realistic use case where divisibility is expressed.
    
    Neither related restrictions could be identified in the sources
    [1] nor MongoDB forbids this [2].  Tests also seem to exercise this
    specific case [3].  Thanks @iilyak for checking on these.
    
    [1] https://github.com/apache/couchdb/blob/adf17140e81d0b74f2b2ecdea48fc4f702832eaf/src/mango/src/mango_selector.erl#L512:L513
    [2] https://www.mongodb.com/docs/manual/reference/operator/query/mod/
    [3] https://github.com/apache/couchdb/blob/0059b8f90e58e10b199a4b768a06a762d12a30d3/src/mango/test/03-operator-test.py#L58
---
 src/docs/src/api/database/find.rst | 4 ++--
 src/mango/README.md                | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/docs/src/api/database/find.rst b/src/docs/src/api/database/find.rst
index 2ec5cc646..d1dfe6e65 100644
--- a/src/docs/src/api/database/find.rst
+++ b/src/docs/src/api/database/find.rst
@@ -704,8 +704,8 @@ operators require the argument to be in a specific JSON format.
 |               |             |            | document. Non-array fields cannot |
 |               |             |            | match this condition.             |
 +---------------+-------------+------------+-----------------------------------+
-| Miscellaneous | ``$mod``    | [Divisor,  | Divisor and Remainder are both    |
-|               |             | Remainder] | positive or negative integers.    |
+| Miscellaneous | ``$mod``    | [Divisor,  | Divisor is a non-zero integer,    |
+|               |             | Remainder] | Remainder is any integer.         |
 |               |             |            | Non-integer values result in a    |
 |               |             |            | 404. Matches documents where      |
 |               |             |            | ``field % Divisor == Remainder``  |
diff --git a/src/mango/README.md b/src/mango/README.md
index 4c4bb60a6..9fa273b15 100644
--- a/src/mango/README.md
+++ b/src/mango/README.md
@@ -302,7 +302,7 @@ Array related operators
 
 Misc related operators
 
-* "$mod" - [Divisor, Remainder], where Divisor and Remainder are both positive integers (ie, greater than 0). Matches documents where (field % Divisor == Remainder) is true. This is false for any non-integer field
+* "$mod" - [Divisor, Remainder], where Divisor is a non-zero integer and Remainder is any integer. Matches documents where (field % Divisor == Remainder) is true.  This is false for any non-integer field
 * "$regex" - string, a regular expression pattern to match against the document field. Only matches when the field is a string value and matches the supplied matches