mirror of https://github.com/django/django.git
Minor edits to Greatest/Least docs; refs #24767.
This commit is contained in:
parent
286d0e6ab1
commit
6b41834855
|
@ -89,8 +89,7 @@ class Greatest(Func):
|
||||||
|
|
||||||
If any expression is null the return value is database-specific:
|
If any expression is null the return value is database-specific:
|
||||||
On Postgres, the maximum not-null expression is returned.
|
On Postgres, the maximum not-null expression is returned.
|
||||||
On MySQL, Oracle and SQLite, if any expression is null, null is
|
On MySQL, Oracle, and SQLite, if any expression is null, null is returned.
|
||||||
returned.
|
|
||||||
"""
|
"""
|
||||||
function = 'GREATEST'
|
function = 'GREATEST'
|
||||||
|
|
||||||
|
@ -110,8 +109,7 @@ class Least(Func):
|
||||||
|
|
||||||
If any expression is null the return value is database-specific:
|
If any expression is null the return value is database-specific:
|
||||||
On Postgres, the minimum not-null expression is returned.
|
On Postgres, the minimum not-null expression is returned.
|
||||||
On MySQL, Oracle and SQLite, if any expression is null, null is
|
On MySQL, Oracle, and SQLite, if any expression is null, null is returned.
|
||||||
returned.
|
|
||||||
"""
|
"""
|
||||||
function = 'LEAST'
|
function = 'LEAST'
|
||||||
|
|
||||||
|
|
|
@ -96,13 +96,13 @@ Usage example::
|
||||||
Greatest
|
Greatest
|
||||||
--------
|
--------
|
||||||
|
|
||||||
.. versionadded:: 1.9
|
|
||||||
|
|
||||||
.. class:: Greatest(*expressions, **extra)
|
.. class:: Greatest(*expressions, **extra)
|
||||||
|
|
||||||
|
.. versionadded:: 1.9
|
||||||
|
|
||||||
Accepts a list of at least two field names or expressions and returns the
|
Accepts a list of at least two field names or expressions and returns the
|
||||||
greatest value. Each argument must be of a similar type, so mixing text and numbers
|
greatest value. Each argument must be of a similar type, so mixing text and
|
||||||
will result in a database error.
|
numbers will result in a database error.
|
||||||
|
|
||||||
Usage example::
|
Usage example::
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ Usage example::
|
||||||
>>> comments = Comment.objects.annotate(last_updated=Greatest('modified', 'blog__modified'))
|
>>> comments = Comment.objects.annotate(last_updated=Greatest('modified', 'blog__modified'))
|
||||||
>>> annotated_comment = comments.get()
|
>>> annotated_comment = comments.get()
|
||||||
|
|
||||||
``annotated_comment.last_updated`` will be the most recent of
|
``annotated_comment.last_updated`` will be the most recent of ``blog.modified``
|
||||||
``blog.modified`` and ``comment.modified``.
|
and ``comment.modified``.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
|
@ -131,19 +131,19 @@ Usage example::
|
||||||
|
|
||||||
- PostgreSQL: ``Greatest`` will return the largest non-null expression,
|
- PostgreSQL: ``Greatest`` will return the largest non-null expression,
|
||||||
or ``null`` if all expressions are ``null``.
|
or ``null`` if all expressions are ``null``.
|
||||||
- SQLite, Oracle and MySQL: If any expression is ``null``, ``Greatest``
|
- SQLite, Oracle, and MySQL: If any expression is ``null``, ``Greatest``
|
||||||
will return ``null``.
|
will return ``null``.
|
||||||
|
|
||||||
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
|
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
|
||||||
a sensible minimum value to provide as a default.
|
a sensible minimum value to provide as a default.
|
||||||
|
|
||||||
Least
|
Least
|
||||||
--------
|
-----
|
||||||
|
|
||||||
.. versionadded:: 1.9
|
|
||||||
|
|
||||||
.. class:: Least(*expressions, **extra)
|
.. class:: Least(*expressions, **extra)
|
||||||
|
|
||||||
|
.. versionadded:: 1.9
|
||||||
|
|
||||||
Accepts a list of at least two field names or expressions and returns the
|
Accepts a list of at least two field names or expressions and returns the
|
||||||
least value. Each argument must be of a similar type, so mixing text and numbers
|
least value. Each argument must be of a similar type, so mixing text and numbers
|
||||||
will result in a database error.
|
will result in a database error.
|
||||||
|
@ -155,7 +155,7 @@ will result in a database error.
|
||||||
|
|
||||||
- PostgreSQL: ``Least`` will return the smallest non-null expression,
|
- PostgreSQL: ``Least`` will return the smallest non-null expression,
|
||||||
or ``null`` if all expressions are ``null``.
|
or ``null`` if all expressions are ``null``.
|
||||||
- SQLite, Oracle and MySQL: If any expression is ``null``, ``Least``
|
- SQLite, Oracle, and MySQL: If any expression is ``null``, ``Least``
|
||||||
will return ``null``.
|
will return ``null``.
|
||||||
|
|
||||||
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
|
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
|
||||||
|
|
Loading…
Reference in New Issue