Kaydet (Commit) 14dead04 authored tarafından Ian Foote's avatar Ian Foote Kaydeden (comit) Marc Tamlyn

Fixed #24925 -- Document using Coalesce on MySQL

Add warning for using Coalesce with python values on MySQL and document
workaround.
üst 4ab53a55
...@@ -55,6 +55,17 @@ Usage examples:: ...@@ -55,6 +55,17 @@ Usage examples::
>>> print(aggregated['combined_age_default']) >>> print(aggregated['combined_age_default'])
None 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 Concat
------ ------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment