#13666: Updates with F objects on decimal fields raise MySQL warnings
-------------------------------------+-------------------------------------
     Reporter:  KyleMac              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by jarshwah):

 Wouldn't it make sense to pass the number verbatim rather than
 stringifying it? Or could that introduce inconsistencies with floats being
 imprecise? What about the other backends, do they all accept string-like
 decimal numbers and happily call them decimals?

 If we want to go with a wrapping type though, it should be possible (from
 1.8/master) to provide an `as_mysql()` for the Value expression.

 Something like:

 {{{
 class Value(..):
     def as_mysql(self, compiler, connection):
         if self.output_field.get_internal_type() == 'DecimalField':
                 c = Cast(self, self.output_field)
                 return compiler.compile(c)
 }}}

 Where the `Cast` type above would need to be implemented in some way. The
 implementation could be thorough and apply to all backends (quite a bit of
 work), or it could be extremely simple, and only work for Decimal types on
 MySQL. There's similar logic for Oracle with the `Coalesce` type and
 conversions to NCLOB.

 I'd be wary about providing the digits and precision arguments to the CAST
 if they aren't exactly needed. If they can be avoided, then do so. Because
 there's no nice way (currently) to pass that information.

--
Ticket URL: <https://code.djangoproject.com/ticket/13666#comment:13>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.16cc82bcdfb6557234df6a475da883df%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to