Skip to content

Commit

Permalink
Docs: Clarify negation operator in QueryBuilder filters (#5985)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
  • Loading branch information
JPchico and sphuber committed May 2, 2023
1 parent 5e92f5e commit 2c82881
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/source/howto/query.rst
Expand Up @@ -150,7 +150,12 @@ In case you want all calculation jobs with state ``finished`` or ``excepted``, y
},
)
You can negate a filter by adding an exclamation mark in front of the operator.
.. _how-to:query:filters:operator-negations:

Operator negations
------------------

A filter can be turned into its associated **negation** by adding an exclamation mark, ``!``, in front of the operator.
So, to query for all calculation jobs that are not a ``finished`` or ``excepted`` state:

.. code-block:: python
Expand Down
7 changes: 7 additions & 0 deletions docs/source/topics/database.rst
Expand Up @@ -178,6 +178,13 @@ List of all operators:
| ``contains`` | lists | ``'attributes.some_key': {'contains': ['a', 'b']}`` | Filter for lists that should contain certain values. |
+--------------+-------------+-------------------------------------------------------+------------------------------------------------------------------------------+

As mentioned in the :ref:`section about operatior negations<how-to:query:filters:operator-negations>` all operators can be turned into their associated negation (``NOT`` operator) by adding a ``!`` in front of the operator.

.. note::
The form of (negation) operators in the rendered SQL may differ from the ones specified in the ``QueryBuilder`` instance.
For example, the ``!==`` operator of the ``QueryBuilder`` will be rendered to ``!=`` in SQL.


.. _topics:database:advancedquery:tables:relationships:

List of all relationships:
Expand Down

0 comments on commit 2c82881

Please sign in to comment.