Fixed #24925 -- Document using Coalesce on MySQL

Add warning for using Coalesce with python values on MySQL and document
workaround.
This commit is contained in:
Ian Foote 2015-06-05 10:49:12 +01:00 committed by Marc Tamlyn
parent 4ab53a558a
commit 14dead04ac
1 changed files with 11 additions and 0 deletions

View File

@ -55,6 +55,17 @@ Usage examples::
>>> print(aggregated['combined_age_default'])
None
.. warning::
A python value passed to ``Coalesce`` on MySQL may be converted to an
incorrect type unless explicitly cast to the correct database type:
>>> from django.db.models.expressions import RawSQL
>>> from django.utils import timezone
>>> now = timezone.now()
>>> now_sql = RawSQL("cast(%s as datetime)", (now,))
>>> Coalesce('updated', now_sql)
Concat
------