Django

Code

Changeset 7485

Show
Ignore:
Timestamp:
04/27/08 19:03:01 (2 months ago)
Author:
adrian
Message:

Added some tests to modeltests/many_to_one that demonstrate a post-queryset-refactor bug in dates(). Refs #7097

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/many_to_one/models.py

    r7477 r7485  
    247247[<Reporter: John Smith>] 
    248248 
    249 # Check that implied __exact also works 
     249# Check that implied __exact also works. 
    250250>>> Reporter.objects.filter(article__reporter=r).distinct() 
    251251[<Reporter: John Smith>] 
     
    267267[<Reporter: John Smith>] 
    268268 
    269 # Deletes using a join in the query 
     269# You can delete using a JOIN in the query. 
    270270>>> Reporter.objects.filter(article__headline__startswith='This').delete() 
    271271>>> Reporter.objects.all() 
     
    274274[] 
    275275 
     276# Check that Article.objects.select_related().dates() works properly when 
     277# there are multiple Articles with the same date but different foreign-key 
     278# objects (Reporters). 
     279>>> r1 = Reporter.objects.create(first_name='Mike', last_name='Royko', email='royko@suntimes.com') 
     280>>> r2 = Reporter.objects.create(first_name='John', last_name='Kass', email='jkass@tribune.com') 
     281>>> a1 = Article.objects.create(headline='First', pub_date=datetime(1980, 4, 23), reporter=r1) 
     282>>> a2 = Article.objects.create(headline='Second', pub_date=datetime(1980, 4, 23), reporter=r2) 
     283>>> Article.objects.select_related().dates('pub_date', 'day') 
     284[datetime.datetime(1980, 4, 23, 0, 0)] 
     285>>> Article.objects.select_related().dates('pub_date', 'month') 
     286[datetime.datetime(1980, 4, 1, 0, 0)] 
     287>>> Article.objects.select_related().dates('pub_date', 'year') 
     288[datetime.datetime(1980, 1, 1, 0, 0)] 
    276289"""}