mirror of
https://github.com/django/django.git
synced 2025-11-01 20:31:40 +00:00
Refs #28643 -- Added NullIf database function.
Thanks Nick Pope, Mariusz Felisiak, and Tim Graham for reviews.
This commit is contained in:
parent
217f4456d8
commit
4b9d72210f
6 changed files with 78 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue