#15579: Please add support to delete specialization , while preserving base 
class
instance (multi-table inheritance)
-------------------------------------+-------------------------------------
               Reporter:  zimnyx     |        Owner:  nobody
                 Status:  reopened   |    Milestone:
              Component:  Database   |      Version:  SVN
  layer (models, ORM)                |     Keywords:
             Resolution:             |    Has patch:  0
           Triage Stage:             |  Needs tests:  0
  Unreviewed                         |
    Needs documentation:  0          |
Patch needs improvement:  0          |
-------------------------------------+-------------------------------------
Changes (by zimnyx):

 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 It doesn't seem to work.

 Please take a look on this sample code:
 {{{
 class List(models.Model):
     name = models.CharField(max_length=10)

 class SpecificList(List):
     specific_name = models.CharField(max_length=10)
 }}}

 Let's create specialization instance
 {{{
 >>> s = SpecificList(name='bear', specific_name='sasquatch')
 >>> s.save()
 110315 11:48:35    21 Query     INSERT INTO `list_list` (`name`) VALUES
 ('bear')
                    21 Query     commit
                    21 Query     SELECT ** FROM `list_specificlist` WHERE
 `list_specificlist`.`list_ptr_id` = 3  LIMIT 1
                    21 Query     INSERT INTO `list_specificlist`
 (`list_ptr_id`, `specific_name`) VALUES (3, 'sasquatch')
                    21 Query     commit
 }}}

 And now delete (upcast) it as you suggested:

 {{{
 >>> s.list_ptr = None
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/srv/django-bugi/nowa/mypro/django/db/models/fields/related.py",
 line 327, in __set__
     (instance._meta.object_name, self.field.name))
 ValueError: Cannot assign None: "SpecificList.list_ptr" does not allow
 null values.
 }}}

 I also tried setting *_ptr_id to None and then delete:

 {{{
 >>> s.list_ptr_id = None
 >>> s.delete()
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/srv/django-bugi/nowa/mypro/django/db/models/base.py", line 577,
 in delete
     assert self._get_pk_val() is not None, "%s object can't be deleted
 because its %s attribute is set to None." % (self._meta.object_name,
 self._meta.pk.attname)
 AssertionError: SpecificList object can't be deleted because its
 list_ptr_id attribute is set to None.
 }}}

 This does not work either.


 Do I misunderstood you or this feature just doesn't work?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15579#comment:2>
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 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to