diff options
| author | Mads Jensen <mje@inducks.org> | 2018-01-14 22:00:16 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-01-10 12:10:12 -0500 |
| commit | 4b9d72210f0201efeafb9703e166aa3b38c04873 (patch) | |
| tree | 05f193fcbd373c0c6bc22efbbb12b0aa894f8990 /docs/ref | |
| parent | 217f4456d823cdc07b4d8e2721165739e666e1e7 (diff) | |
Refs #28643 -- Added NullIf database function.
Thanks Nick Pope, Mariusz Felisiak, and Tim Graham for reviews.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/databases.txt | 2 | ||||
| -rw-r--r-- | docs/ref/models/database-functions.txt | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 04214a6560..0c584f7110 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -899,6 +899,8 @@ occur when an Oracle datatype is used as a column name. In particular, take care to avoid using the names ``date``, ``timestamp``, ``number`` or ``float`` as a field name. +.. _oracle-null-empty-strings: + NULL and empty strings ---------------------- diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt index f1affb2b6f..2661b65c78 100644 --- a/docs/ref/models/database-functions.txt +++ b/docs/ref/models/database-functions.txt @@ -149,6 +149,25 @@ will result in a database error. The PostgreSQL behavior can be emulated using ``Coalesce`` if you know a sensible maximum value to provide as a default. +``NullIf`` +---------- + +.. class:: NullIf(expression1, expression2) + +.. versionadded:: 2.2 + +Accepts two expressions and returns ``None`` if they are equal, otherwise +returns ``expression1``. + +.. admonition:: Caveats on Oracle + + Due to an :ref:`Oracle convention<oracle-null-empty-strings>`, this + function returns the empty string instead of ``None`` when the expressions + are of type :class:`~django.db.models.CharField`. + + Passing ``Value(None)`` to ``expression1`` is prohibited on Oracle since + Oracle doesn't accept ``NULL`` as the first argument. + .. _date-functions: Date functions |
