#12768: Raw query map problem with some primary keys
------------------------------------------+---------------------------------
 Reporter:  [email protected]             |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Database layer (models, ORM)  |     Version:  SVN       
 Keywords:                                |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 Hello,

 I'm trying the new raw query feature and i'm facing this bug:

 When my model has primary_key set to some ForeignKey and I try to invoke
 the raw() method, !InvalidQuery('Raw query must include the primary key')
 is raised.

 {{{
 class ExampleModel(models.Model):
     some = models.ForeignKey(SomeOther, primary_key=True)

     class Meta:
         db_table = 'example_model'


 ExampleModel.objects.raw("SELECT some_id FROM example_model")
 }}}

 The problem arise because get_attname_column gives (some_id, some_id) as
 name/column but then it is compared to _meta.pk.attname (some) here:
 {{{
         if skip:
             if self.model._meta.pk.attname in skip:
                 raise InvalidQuery('Raw query must include the primary
 key')
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12768>
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