#11263: Bug in lookup with generic relation in model inheritance
---------------------------------------------------+------------------------
          Reporter:  veena                         |         Owner:  tobias     
                         
            Status:  assigned                      |     Milestone:  1.2        
                         
         Component:  Database layer (models, ORM)  |       Version:  SVN        
                         
        Resolution:                                |      Keywords:  generic 
relations, model inheritance
             Stage:  Accepted                      |     Has_patch:  0          
                         
        Needs_docs:  1                             |   Needs_tests:  1          
                         
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Comment (by tobias):

 WITH inheritance it still breaks in trunk:

 {{{
 rom django.db import models
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
 from django.contrib.auth.models import User

 class Order(models.Model):
     content_type = models.ForeignKey(ContentType)
     object_id = models.PositiveIntegerField()
     content_object = generic.GenericForeignKey()
     status = models.CharField(max_length=10, default='ordered')

 class Visitor(User): # HAS a parent model
     order = generic.GenericRelation(Order)


 Visitor.objects.filter(order__status='ordered').count()
 # generates:
 ProgrammingError: column testapp_order.user_ptr_id does not exist
 }}}

 {{{
 SELECT COUNT(*)
 FROM "testapp_visitor"
 INNER JOIN "testapp_order" ON ("testapp_visitor"."user_ptr_id" =
 "testapp_order"."object_id")
 INNER JOIN "testapp_order" T3 ON ("testapp_order"."user_ptr_id" = T3."id")
 WHERE (T3."status" = E\'ordered\'  AND T3."content_type_id" = 9 )
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11263#comment:6>
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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to