Modify ↓
Ticket #741 (assigned defect)
CharField false change detection (Null attribute)
| Reported by: | uti_sis@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0 |
| Component: | migrations | Version: | 0.7.3 |
| Keywords: | postgres, charfield, null | Cc: |
Description
We have a model with CharField? fields without null attribute (Django default appĺies: false)
i.e.
foo = models.CharField(max_length=250)
Our initial migration shows
db.create_table(...
(...),
('foo', self.gf('django.db.models.fields.CharField')(max_length=250)),
))
We changed models.py without affecting field definitions.
The next migration create lines like this
db.alter_column('fooapp_footable', 'foo',
self.gf('django.db.models.fields.CharField')(max_length=250, null=True))
The same happen to all the CharFields?.
We expected to have no change at all (no migration file or an empty one), so this seems to be a bug.
Also, when the migration is applied, the database remains unchanged.
We have:
- PostgreSQL 8.3
- Django 1.2.3
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

I think there is a bug in:
version-src: south-0.7.3.tar.gz
file: /modelsinspector.py
get_value with parameters field = <django.db.models.fields.CharField? object ...> and defn = ['null', {'default': False}] should return False, but it returns True.
def introspector should return this {'max_length': '250', 'null': 'False'} or {'max_length': '250'} but it returns {'max_length': '250', 'null': 'True'}
All this is generated by freezer.freezer_app function to generate the value of new_defs variable.