#2210: [patch] order_by on related table with db_column different to name fails
------------------------------------------------+---------------------------
Reporter: Russell Cloran <[EMAIL PROTECTED]> | Owner:
adrian
Status: new | Component:
Database wrapper
Version: SVN | Resolution:
Keywords: order_by related | Stage:
Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 1 | Needs_better_patch: 0
------------------------------------------------+---------------------------
Changes (by [EMAIL PROTECTED]):
* keywords: => order_by related
Comment:
This bug is confirmed. Here's a complete example to reproduce the problem:
'''models.py'''
{{{
from django.db import models
class Book(models.Model):
title = models.TextField()
class BookStat(models.Model):
book = models.OneToOneField(Book, related_name='stats')
times_read = models.PositiveIntegerField()
}}}
'''After syncing the DB, in the command line:'''
{{{
>>> from orderby.example.models import *
>>> book = Book.objects.create(title="BFG")
>>> book.save()
>>> bs = BookStat.objects.create(book=book, times_read=15)
>>> bs.save()
>>> Book.objects.all().order_by("stats__times_read")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python25\lib\site-packages\django\db\models\query.py", line
101, in __repr__
return repr(self._get_data())
File "C:\Python25\lib\site-packages\django\db\models\query.py", line
444, in _get_data
self._result_cache = list(self.iterator())
File "C:\Python25\lib\site-packages\django\db\models\query.py", line
181, in iterator
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") +
",".join(select) + sql, params)
File "C:\Python25\lib\site-packages\django\db\backends\util.py", line
12, in execute
return self.cursor.execute(sql, params)
File "C:\Python25\lib\site-
packages\django\db\backends\postgresql\base.py", line 43, in execute
return self.cursor.execute(sql, [smart_basestring(p, self.charset)
for p in params])
ProgrammingError: ERROR: column example_book.stats__times_read does not
exist at character 80
SELECT "example_book"."id","example_book"."title" FROM "example_book"
ORDER BY "example_book"."stats__times_read" ASC
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/2210#comment:11>
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
-~----------~----~----~----~------~----~------~--~---