#5139: Custom primary_key broken when saving
-----------------------------------+----------------------------------------
Reporter:  [EMAIL PROTECTED]  |       Owner:  adrian          
  Status:  new                     |   Component:  Database wrapper
 Version:  SVN                     |    Keywords:  primary_key save
   Stage:  Unreviewed              |   Has_patch:  0               
-----------------------------------+----------------------------------------
 When you save a model instance with a custom primary_key, you can't
 retrieve the primary_key without getting the instance again first.
 With a standard primary_key this works fine (like the documentation says)
 
 Relevant code from my models
 {{{
 #!python
 class XbtFiles(models.Model):
   fid = models.IntegerField(primary_key=True)
   info_hash = models.TextField(unique=True)
 
 class Tag(models.Model):
     name = models.CharField(maxlength=128)
 }}}
 
 With standard primary_key it works fine
 {{{
 #!python
 >>> t=Tag(name="foo")
 >>> t.save()
 >>> t.id
 2L
 }}}
 
 With custom primary_key it is broken
 {{{
 #!python
 >>> x=XbtFiles(info_hash="this_field_is_unique")
 >>> x.save()
 >>> x.info_hash
 'this_field_is_unique'
 >>> x.fid
 >>> #huh nothing???
 >>> y=XbtFiles.objects.get(info_hash="this_field_is_unique")
 >>> x == y
 False
 >>> y.fid
 10L
 }}}

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

Reply via email to