diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2019-03-20 18:30:43 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-03-20 19:30:43 +0100 |
| commit | 0b70985f42da7a8eb2e206e6780681b7849564ef (patch) | |
| tree | 5bd1eef1e638abde2a36646a3e769fc83536fb74 /docs | |
| parent | 0193bf874f08f21cdec628b8d80d261471bfe5fc (diff) | |
Fixed #30240 -- Added SHA1, SHA224, SHA256, SHA384, and SHA512 database functions.
Thanks Mariusz Felisiak and Tim Graham for reviews.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/database-functions.txt | 35 | ||||
| -rw-r--r-- | docs/releases/3.0.txt | 7 |
2 files changed, 41 insertions, 1 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`` ------------ diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt index 3433d54183..71a8aef971 100644 --- a/docs/releases/3.0.txt +++ b/docs/releases/3.0.txt @@ -168,7 +168,12 @@ Migrations Models ~~~~~~ -* Added the :class:`~django.db.models.functions.MD5` database function. +* Added hash database functions :class:`~django.db.models.functions.MD5`, + :class:`~django.db.models.functions.SHA1`, + :class:`~django.db.models.functions.SHA224`, + :class:`~django.db.models.functions.SHA256`, + :class:`~django.db.models.functions.SHA384`, and + :class:`~django.db.models.functions.SHA512`. * The new ``is_dst`` parameter of the :class:`~django.db.models.functions.Trunc` database functions determines the |
