Changes between Initial Version and Version 1 of Ticket #15082


Ignore:
Timestamp:
01/14/2011 08:11:50 AM (8 years ago)
Author:
Russell Keith-Magee
Comment:

Corrected formatting. Please use preview.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #15082 – Description

    initial v1  
    11I'm working with MyISAM tables with MySQL and have the following behavior with delete() on Django 1.2.3-1 on Fedora Core 12.
    2 
     2{{{
    33class DoesWork(models.Model):
    44    mac_id = models.CharField(max_length=17)
     
    88    mac_id = models.CharField(max_length=17, primary_key=True)
    99    ip = models.CharField('Host/IP Address', max_length=255)
    10 
     10}}}
    1111The following works as expected, creating, deleting, and putting the item back:
     12{{{
    1213zz = DoesWork.objects.create(mac_id='99:99:99:99:99:99', ip='127.0.0.1')
    1314zz.delete() # remove from DB
    1415zz.save() # it's back in the DB
    15 
     16}}}
    1617However, if I use the DoesNotWork model, whose only difference is having a CharField as a primary key:
     18{{{
    1719zz = DoesNotWork.objects.create(mac_id='99:99:99:99:99:99', ip='127.0.0.1')
    1820zz.delete() # remove from DB
     
    2022
    2123IntegrityError: (1048, "Column 'mac_id' cannot be null")
    22 
    23 I checked by printing out zz.__dict__, and the mac_id was 'None' with the DoesNotWork object, but was untouched with the DoesWork object.
     24}}}
     25I checked by printing out zz.!__dict!__, and the mac_id was 'None' with the DoesNotWork object, but was untouched with the DoesWork object.
Back to Top