Ticket #11392: result_set_ordering.diff

File result_set_ordering.diff, 3.6 KB (added by nauch, 15 years ago)
  • modeltests/transactions/models.py

     
    5050Exception: I meant to do that
    5151
    5252# Same behavior as before
    53 >>> Reporter.objects.all()
     53>>> Reporter.objects.order_by('id')
    5454[<Reporter: Alice Smith>, <Reporter: Ben Jones>]
    5555
    5656# With the commit_on_success decorator, the transaction is only comitted if the
     
    6262Exception: I meant to do that
    6363
    6464# This time the object never got saved
    65 >>> Reporter.objects.all()
     65>>> Reporter.objects.order_by('id')
    6666[<Reporter: Alice Smith>, <Reporter: Ben Jones>]
    6767
    6868# If there aren't any exceptions, the data will get saved
     
    8383...     transaction.commit()
    8484>>> manually_managed = transaction.commit_manually(manually_managed)
    8585>>> manually_managed()
    86 >>> Reporter.objects.all()
     86>>> Reporter.objects.order_by('id')
    8787[<Reporter: Ben Jones>, <Reporter: Carol Doe>]
    8888
    8989# If you forget, you'll get bad errors
  • regressiontests/null_fk/models.py

     
    4444>>> print c.post
    4545None
    4646
    47 >>> comments = Comment.objects.select_related('post__forum__system_info').all()
     47>>> comments = Comment.objects.select_related('post__forum__system_info').order_by('id')
    4848>>> [(c.id, c.comment_text, c.post) for c in comments]
    4949[(1, u'My first comment', <Post: First Post>), (2, u'My second comment', None)]
    5050
  • regressiontests/serializers_regress/tests.py

     
    103103def generic_compare(testcase, pk, klass, data):
    104104    instance = klass.objects.get(id=pk)
    105105    testcase.assertEqual(data[0], instance.data)
    106     testcase.assertEqual(data[1:], [t.data for t in instance.tags.all()])
     106    testcase.assertEqual(data[1:], [t.data for t in instance.tags.order_by('id')])
    107107
    108108def fk_compare(testcase, pk, klass, data):
    109109    instance = klass.objects.get(id=pk)
     
    111111
    112112def m2m_compare(testcase, pk, klass, data):
    113113    instance = klass.objects.get(id=pk)
    114     testcase.assertEqual(data, [obj.id for obj in instance.data.all()])
     114    testcase.assertEqual(data, [obj.id for obj in instance.data.order_by('id')])
    115115
    116116def im2m_compare(testcase, pk, klass, data):
    117117    instance = klass.objects.get(id=pk)
  • regressiontests/aggregation_regress/models.py

     
    264264[<Book: Artificial Intelligence: A Modern Approach>, <Book: Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp>, <Book: Practical Django Projects>, <Book: Python Web Development with Django>, <Book: Sams Teach Yourself Django in 24 Hours>, <Book: The Definitive Guide to Django: Web Development Done Right>]
    265265
    266266# Regression for #10248 - Annotations work with DateQuerySets
    267 >>> Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate', 'day')
     267>>> sorted(Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate', 'day'))
    268268[datetime.datetime(1995, 1, 15, 0, 0), datetime.datetime(2007, 12, 6, 0, 0)]
    269269
    270270# Regression for #10290 - extra selects with parameters can be used for
Back to Top