Kaydet (Commit) ad8f6a45 authored tarafından Simon Charette's avatar Simon Charette Kaydeden (comit) Tim Graham

Replaced RawSQL with Cast in Coalesce doc example.

üst cc9e4297
...@@ -76,11 +76,11 @@ Usage examples:: ...@@ -76,11 +76,11 @@ Usage examples::
A Python value passed to ``Coalesce`` on MySQL may be converted to an A Python value passed to ``Coalesce`` on MySQL may be converted to an
incorrect type unless explicitly cast to the correct database type: incorrect type unless explicitly cast to the correct database type:
>>> from django.db.models.expressions import RawSQL >>> from django.db.models import DateTimeField
>>> from django.db.models.functions import Cast, Coalesce
>>> from django.utils import timezone >>> from django.utils import timezone
>>> now = timezone.now() >>> now = timezone.now()
>>> now_sql = RawSQL("cast(%s as datetime)", (now,)) >>> Coalesce('updated', Cast(now, DateTimeField()))
>>> 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