Ticket #741 (assigned defect)

Opened 5 years ago

Last modified 5 years ago

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:


We have a model with CharField? fields without null attribute (Django default appĺies: false)


    foo = models.CharField(max_length=250)

Our initial migration shows

            ('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

Change History

comment:1 Changed 5 years ago by uti_sis@…

I think there is a bug in:
version-src: south-0.7.3.tar.gz
file: /modelsinspector.py

def introspector
line 297: kwargs[kwd] = get_value(field, defn)

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.

comment:2 Changed 5 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 1.0
Note: See TracTickets for help on using tickets.