1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #21181 -- Added Collate database function.

Thanks Simon Charette for reviews.
This commit is contained in:
Tom Carrick
2020-08-08 13:37:06 +02:00
committed by Mariusz Felisiak
parent 60626162f7
commit 63300f7e68
10 changed files with 121 additions and 2 deletions

View File

@@ -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``
------------