summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTom Carrick <tom@carrick.eu>2020-08-08 13:37:06 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-11 22:21:08 +0200
commit63300f7e686c2c452763cb512df9abf7734fd588 (patch)
tree79526757ff463d5706ee879f06b3dd46780f6c19 /docs
parent60626162f76f26d32a38d18151700cb041201fb3 (diff)
Fixed #21181 -- Added Collate database function.
Thanks Simon Charette for reviews.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/database-functions.txt19
-rw-r--r--docs/releases/3.2.txt3
2 files changed, 22 insertions, 0 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index da67d9e362..f5efdb7e87 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -87,6 +87,25 @@ Usage examples::
>>> now = timezone.now()
>>> Coalesce('updated', Cast(now, DateTimeField()))
+``Collate``
+-----------
+
+.. class:: Collate(expression, collation)
+
+.. versionadded:: 3.2
+
+Takes an expression and a collation name to query against.
+
+For example, to filter case-insensitively in SQLite::
+
+ >>> Author.objects.filter(name=Collate(Value('john'), 'nocase'))
+ <QuerySet [<Author: John>, <Author: john>]>
+
+It can also be used when ordering, for example with PostgreSQL::
+
+ >>> Author.objects.order_by(Collate('name', 'et-x-icu'))
+ <QuerySet [<Author: Ursula>, <Author: Veronika>, <Author: Ülle>]>
+
``Greatest``
------------
diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt
index 23b687f593..41929172c6 100644
--- a/docs/releases/3.2.txt
+++ b/docs/releases/3.2.txt
@@ -273,6 +273,9 @@ Models
expressions that don't need to be selected but are used for filtering,
ordering, or as a part of complex expressions.
+* The new :class:`~django.db.models.functions.Collate` function allows
+ filtering and ordering by specified database collations.
+
Pagination
~~~~~~~~~~