summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-28 02:27:19 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-28 02:27:19 +0000
commit356dfd5308aeace4c2f46405debbbac37890e0bb (patch)
tree9015a23284a4698f6307eb6954392159592e3658
parent6d986360183101c26c51adee4229bc038e63e441 (diff)
Fixed #7098 -- Old-style related-model order_by() syntax was being incorrectly
marked as erroneous. It's just more dangerous and risky, not forbidden. This commit restores backwards compatibility there. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7490 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/models/sql/constants.py2
-rw-r--r--tests/regressiontests/queries/models.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/sql/constants.py b/django/db/models/sql/constants.py
index 3075817385..129a592b31 100644
--- a/django/db/models/sql/constants.py
+++ b/django/db/models/sql/constants.py
@@ -28,7 +28,7 @@ NULLABLE = 6
MULTI = 'multi'
SINGLE = 'single'
-ORDER_PATTERN = re.compile(r'\?|[-+]?\w+$')
+ORDER_PATTERN = re.compile(r'\?|[-+]?[.\w]+$')
ORDER_DIR = {
'ASC': ('ASC', 'DESC'),
'DESC': ('DESC', 'ASC')}
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 483aa7218c..5529bced8b 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -654,5 +654,9 @@ Bug #7045 -- extra tables used to crash SQL construction on the second use.
>>> s = qs.query.as_sql()
>>> s = qs.query.as_sql() # test passes if this doesn't raise an exception.
+Bug #7098 -- Make sure semi-deprecated ordering by related models syntax still
+works.
+>>> Item.objects.values('note__note').order_by('queries_note.note', 'id')
+[{'note__note': u'n2'}, {'note__note': u'n3'}, {'note__note': u'n3'}, {'note__note': u'n3'}]
"""}