diff options
| author | Ian Foote <ian@incuna.com> | 2015-06-05 10:49:12 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-06-05 11:18:58 +0100 |
| commit | 14dead04acf4ac877d0f4025f142fe9e872ce8ac (patch) | |
| tree | 85185faeb4e6a8464bf2fe640b176dbfb65b0a9b /docs | |
| parent | 4ab53a558ac01c2dd7dafb8350cd72c630372335 (diff) | |
Fixed #24925 -- Document using Coalesce on MySQL
Add warning for using Coalesce with python values on MySQL and document
workaround.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/database-functions.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt index 8d44d5eaa6..62b65b8858 100644 --- a/docs/ref/models/database-functions.txt +++ b/docs/ref/models/database-functions.txt @@ -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 ------ |
