1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #9406 -- Ensure that each database column is only represented once in the

"ORDER BY" clause of an SQL statement.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9251 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2008-10-24 06:09:47 +00:00
parent e3aa9a2828
commit 9319dc496c
2 changed files with 27 additions and 7 deletions

View File

@@ -257,4 +257,14 @@ DoesNotExist: ArticleWithAuthor matching query does not exist.
# without error.
>>> _ = QualityControl.objects.create(headline="Problems in Django", pub_date=datetime.datetime.now(), quality=10, assignee="adrian")
# Ordering should not include any database column more than once (this is most
# likely to ocurr naturally with model inheritance, so we check it here).
# Regression test for #9390. This necessarily pokes at the SQL string for the
# query, since the duplicate problems are only apparent at that late stage.
>>> sql = ArticleWithAuthor.objects.order_by('pub_date', 'pk').query.as_sql()[0]
>>> fragment = sql[sql.find('ORDER BY'):]
>>> pos = fragment.find('pub_date')
>>> fragment.find('pub_date', pos + 1) == -1
True
"""}