From c59ea268451246a8693c4dd0987ec9bd39cdcd96 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Wed, 24 Apr 2013 11:17:21 +0000 Subject: [PATCH] Updated docs to clarify or != | (##288) --- docs/guide/querying.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/guide/querying.rst b/docs/guide/querying.rst index 5e250cea..60702ec6 100644 --- a/docs/guide/querying.rst +++ b/docs/guide/querying.rst @@ -392,6 +392,7 @@ You can also turn off all dereferencing for a fixed period by using the Advanced queries ================ + Sometimes calling a :class:`~mongoengine.queryset.QuerySet` object with keyword arguments can't fully express the query you want to use -- for example if you need to combine a number of constraints using *and* and *or*. This is made @@ -410,6 +411,11 @@ calling it with keyword arguments:: # Get top posts Post.objects((Q(featured=True) & Q(hits__gte=1000)) | Q(hits__gte=5000)) +.. warning:: You have to use bitwise operators. You cannot use ``or``, ``and`` + to combine queries as ``Q(a=a) or Q(b=b)`` is not the same as + ``Q(a=a) | Q(b=b)``. As ``Q(a=a)`` equates to true ``Q(a=a) or Q(b=b)`` is + the same as ``Q(a=a)``. + .. _guide-atomic-updates: Atomic updates