#9406: Query.as_sql() generates invalid ORDER BY clause
---------------------------+------------------------------------------------
 Reporter:  egenix_viktor  |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.0       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 Backend: SQLite

 Test case: `regressiontests/model_inheritance_regress`

 Statement: `c1.get_next_by_pub_date()`

 The `Query.as_sql()` method in `django.db.models.sql.query` generates two
 ordering items for the same
 `"model_inheritance_regress_article"."pub_date"` field:

 (The generated query has been split into multiple lines for readability.)

 {{{
 SELECT
     "model_inheritance_regress_article"."id",
     "model_inheritance_regress_article"."headline",
     "model_inheritance_regress_article"."pub_date",
     "model_inheritance_regress_articlewithauthor"."article_ptr_id",
     "model_inheritance_regress_articlewithauthor"."author"
 FROM "model_inheritance_regress_articlewithauthor"
 INNER JOIN "model_inheritance_regress_article"
 ON ("model_inheritance_regress_articlewithauthor"."article_ptr_id" =
 "model_inheritance_regress_article"."id")
 WHERE (
     "model_inheritance_regress_article"."pub_date" > %s OR  (
         "model_inheritance_regress_articlewithauthor"."article_ptr_id" >
 %s AND
         "model_inheritance_regress_article"."pub_date" = %s ))
 ORDER BY
     "model_inheritance_regress_article"."pub_date" ASC,
     "model_inheritance_regress_article"."pub_date" DESC,
     "model_inheritance_regress_article"."headline" ASC
 LIMIT 1
 }}}

 Parameters:

 {{{
 (u'2005-08-01 03:00:00', 1, u'2005-08-01 03:00:00')
 }}}

 It works on SQLite for some reason, but such an `ORDER BY` clause causes
 an error message on many database servers, such as on MS SQL Server 2005
 (when used with another backend, certainly).

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9406>
Django <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 django-updates@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to