summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2019-03-20 18:30:43 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-03-20 19:30:43 +0100
commit0b70985f42da7a8eb2e206e6780681b7849564ef (patch)
tree5bd1eef1e638abde2a36646a3e769fc83536fb74 /docs/ref
parent0193bf874f08f21cdec628b8d80d261471bfe5fc (diff)
Fixed #30240 -- Added SHA1, SHA224, SHA256, SHA384, and SHA512 database functions.
Thanks Mariusz Felisiak and Tim Graham for reviews.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/database-functions.txt35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index 46b41251a0..b79f7972cf 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -1441,6 +1441,41 @@ side.
Similar to :class:`~django.db.models.functions.Trim`, but removes only trailing
spaces.
+``SHA1``, ``SHA224``, ``SHA256``, ``SHA384``, and ``SHA512``
+------------------------------------------------------------
+
+.. class:: SHA1(expression, **extra)
+.. class:: SHA224(expression, **extra)
+.. class:: SHA256(expression, **extra)
+.. class:: SHA384(expression, **extra)
+.. class:: SHA512(expression, **extra)
+
+.. versionadded:: 3.0
+
+Accepts a single text field or expression and returns the particular hash of
+the string.
+
+They can also be registered as transforms as described in :class:`Length`.
+
+Usage example::
+
+ >>> from django.db.models.functions import SHA1
+ >>> Author.objects.create(name='Margaret Smith')
+ >>> author = Author.objects.annotate(name_sha1=SHA1('name')).get()
+ >>> print(author.name_sha1)
+ b87efd8a6c991c390be5a68e8a7945a7851c7e5c
+
+.. admonition:: PostgreSQL
+
+ The `pgcrypto extension <https://www.postgresql.org/docs/current/static/
+ pgcrypto.html>`_ must be installed. You can use the
+ :class:`~django.contrib.postgres.operations.CryptoExtension` migration
+ operation to install it.
+
+.. admonition:: Oracle
+
+ Oracle doesn't support the ``SHA224`` function.
+
``StrIndex``
------------