Code

Changes between Initial Version and Version 1 of Ticket #4136, comment 24


Ignore:
Timestamp:
07/18/12 17:30:56 (21 months ago)
Author:
msopacua
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #4136, comment 24

    initial v1  
    22 
    33Also the simplest option is to always insert as NULL if null and unique are True as there are very few real world cases where an empty value is an actual valid option. One could also make this case for non-unique but null fields, however there's no actual distinction between a NULL value and an empty string in this case. 
     4 
     5And there may be another solution. Backwards compatibility may be an issue but I think solvable. Instead of the blank field being a boolean, make it an integer flag: 
     6- blank = models.RESTRICT acts as blank=False now 
     7- blank = models.SET_EMPTY acts as blank=True now and sets field to the 'empty' value 
     8- blank = models.SET_DEFAULT sets a blank value to the field's default value 
     9- blank = models.SET_NULL sets a blank value to the NULL if null=True or raises ValueError if null=False 
     10 
     11If RESTRICT and SET_EMPTY are 0 and 1 respectively the setting can be set coerced to int and be backwards compatible. All in all I think the cleanest solution in the long run.