#12239: Float is rounded to integer on queries on integer field
------------------------------------------+---------------------------------
 Reporter:  waverider                     |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Core framework                |     Version:  1.1       
 Keywords:  __gte, __lte, query rounding  |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 On queries (__gte, __lte) ran on an integer field with a float value to
 compare, the float value gets rounded to integer and this causes invalid
 results.

 {{{
 class Number(models.Model):
         val = models.IntegerField()

 # Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
 (Intel)] on win32
 # Type "help", "copyright", "credits" or "license" for more information.
 # (InteractiveConsole)

 >>> n = Number(val=10)
 >>> n.save()
 >>> Number.objects.all()
 [<Number: Number object>]
 >>> Number.objects.filter(val__gte=10.1)
 [<Number: Number object>]
 >>> from django.db import connection
 >>> connection.queries[-1]
 {'time': '0.001', 'sql': 'SELECT "t1_number"."id", "t1_number"."val" FROM
 "t1_number" WHERE "t1_number"."val" >= 10  LIMIT 21'}
 >>> import django
 >>> django.VERSION
 (1, 1, 1, 'final', 0)

 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12239>
Django <http://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 post to this group, send email to [email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=.


Reply via email to