From 5240b83462ba4887b67da8d493dfdc23fec5df97 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 21 Feb 2013 23:02:18 +0100 Subject: Fixed #17027 -- Added support for the power operator in F expressions. Thanks dan at dlo.me for the initial patch. - Added __pow__ and __rpow__ to ExpressionNode - Added oracle and mysql specific power expressions - Added used-defined power function for sqlite --- docs/ref/models/queries.txt | 4 ++++ docs/releases/1.7.txt | 3 +++ docs/topics/db/queries.txt | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/ref/models/queries.txt b/docs/ref/models/queries.txt index ebc5142b30..bf7480ef69 100644 --- a/docs/ref/models/queries.txt +++ b/docs/ref/models/queries.txt @@ -112,6 +112,10 @@ As well as addition, Django supports subtraction, multiplication, division, and modulo arithmetic with ``F()`` objects, using Python constants, variables, and even other ``F()`` objects. +.. versionadded:: 1.7 + + The power operator ``**`` is also supported. + ``Q()`` objects =============== diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 699566f1d3..542efc46b9 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -346,6 +346,9 @@ Models :attr:`~django.db.models.ForeignKey.related_name` to `'+'` or ending it with `'+'`. +* :class:`F expressions ` support the power operator + (``**``). + Signals ^^^^^^^ diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index 1180022d6e..7b38dbaea3 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -610,12 +610,16 @@ and use that ``F()`` object in the query:: >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks')) Django supports the use of addition, subtraction, multiplication, -division and modulo arithmetic with ``F()`` objects, both with constants +division, modulo, and power arithmetic with ``F()`` objects, both with constants and with other ``F()`` objects. To find all the blog entries with more than *twice* as many comments as pingbacks, we modify the query:: >>> Entry.objects.filter(n_comments__gt=F('n_pingbacks') * 2) +.. versionadded:: 1.7 + + The power operator ``**`` was added. + To find all the entries where the rating of the entry is less than the sum of the pingback count and comment count, we would issue the query:: -- cgit v1.3