Ticket #765 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Oracle: proper altering of columns with NULL/NOT NULL

Reported by: Nikolay Zakharov <nikolay@…> Owned by: andrew
Priority: major Milestone: 1.0
Component: databaseapi Version: unknown
Keywords: oracle alter ORA-01442 ORA-01451 Cc:


I'll start with a real-life example. I have app with model Staff that have field

position = models.CharField(max_length=150, null=True)

One of the migrations in that app is a simple altering of max_length from 100 to 150. Autogenerated code:

    'intranet_staff', 'position',
    self.gf('django.db.models.fields.CharField')(max_length=150, null=True))

Current oracle backend generates following SQL:


But oracle complains with one of the exceptions ORA-01442 or ORA-01451 that it can't set NULL to column that is already NULL. Current code catches this exception and silently suppresses it, leaving column unaltered. I don't fully understand why one need to suppress database error on altering, but it is evident that in use case shown above this leads to silent ignore of column altering. Proper sql in my case would be


I've changed handling of exceptions mentioned above and now if one occures, sql executes again but without nullity part.

Corresponding changeset: https://bitbucket.org/freevoid/south/changeset/b8f61044aea9

Change History

comment:1 Changed 5 years ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone set to 1.0

Thanks - pulled!

Note: See TracTickets for help on using tickets.