Changes between Initial Version and Version 1 of Ticket #15082
- Timestamp:
- Jan 14, 2011, 8:11:50 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #15082 – Description
initial v1 1 1 I'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 {{{ 3 3 class DoesWork(models.Model): 4 4 mac_id = models.CharField(max_length=17) … … 8 8 mac_id = models.CharField(max_length=17, primary_key=True) 9 9 ip = models.CharField('Host/IP Address', max_length=255) 10 10 }}} 11 11 The following works as expected, creating, deleting, and putting the item back: 12 {{{ 12 13 zz = DoesWork.objects.create(mac_id='99:99:99:99:99:99', ip='127.0.0.1') 13 14 zz.delete() # remove from DB 14 15 zz.save() # it's back in the DB 15 16 }}} 16 17 However, if I use the DoesNotWork model, whose only difference is having a CharField as a primary key: 18 {{{ 17 19 zz = DoesNotWork.objects.create(mac_id='99:99:99:99:99:99', ip='127.0.0.1') 18 20 zz.delete() # remove from DB … … 20 22 21 23 IntegrityError: (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 }}} 25 I checked by printing out zz.!__dict!__, and the mac_id was 'None' with the DoesNotWork object, but was untouched with the DoesWork object.