#8931: Queries on datetimefields return incorrect results in mysql
----------------------------------+-----------------------------------------
 Reporter:  ElliottM              |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  Database wrapper      |     Version:  1.0       
 Keywords:  datetime mysql query  |       Stage:  Unreviewed
Has_patch:  0                     |  
----------------------------------+-----------------------------------------
 In my models, I have a Planet class. One of the fields in Planet is a
 datetime field called updated. I also have a class called Base that has an
 o2o to Planet. The Base class also has an FK called "owner"to the Player
 class.

 When I want to find all the bases whose planets were updated in the last
 six weeks, I should be able to do the following:


 {{{
 six_weeks_ago=datetime.datetime.now()-datetime.timedelta(days=7*6)
 bases=Base.objects.filter(planet__updated__gt=six_weeks_ago)
 }}}

 That query returns no results. However, if I further refine the query to
 get only the bases owned by a particular player, like follows:
 {{{
 player_bases=bases.filter(owner__id=22064)
 }}}

 That query returns 18 results, as expected. It think it's pretty obvious
 that narrowing down the search criteria should reduce the number of
 results, not increase them, and I know there are Bases that have been
 updated in the last 6 weeks.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8931>
Django Code <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]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to