Modify

Ticket #168 (closed defect: fixed)

Opened 3 years ago

Last modified 2 months ago

South fails to add a blank=True/null=False field without manually adding default value

Reported by: Erik Allik Owned by: andrew
Priority: minor Milestone: 0.7
Component: commands Version: 0.6-pre
Keywords: commands migrate Cc:

Description

For example, adding:

my_field = models.CharField(max_length=255, blank=True)

should assume a default value of "", but currently running

db.add_column('myapp_mymodel', 'my_field', models.CharField(max_length=255, blank=True))

gives

psycopg2.IntegrityError: column "my_field" contains null values

...at least on PostgreSQL 8.3, that is.

Not a blocker, but annoyance nevertheless. Using SVN r258.

Attachments

Change History

comment:1 Changed 3 years ago by andrew

  • Milestone changed from 0.6 to 0.7

Not a blocker, but indeed annoying - still, somewhat matches my expectations. Bumping to 0.7.

comment:2 Changed 3 years ago by andrew

  • Status changed from new to assigned

comment:3 Changed 2 years ago by mbarto

  • Cc mbarto added
  • Status changed from assigned to closed
  • Resolution set to fixed

If the field allows empty strings (which CharFields? do) we will manually add the default as empty string "", and at the same time throw ValueError? to avoid this behavior for fields without the ability to allow empty strings (ie. IntegerFields?).

comment:4 Changed 2 years ago by smcoll

i got this same error with a TextField?(blank=True) using 0.6.2. Shouldn't a TextField? have the same behavior as a CharField??

comment:5 Changed 2 years ago by andrew

It probably should do, yes; I'm not sure why it isn't. Could you open a new ticket for this, with information about what database and Django you're using?

comment:6 Changed 2 years ago by anonymous

I don't think this is minor. Adding a blank CharField? or TextField? is one of the simplest, most common use cases, and often the first thing you try with South. This bug--which is in the current stable version--means South throws an exception and fails in that extemely common case.

comment:7 Changed 2 years ago by andrew

This issue is fixed in the upcoming development release of South, so there's no need to re-open it.

Also, for the record, many people do add CharFields? and TextFields? all the time, and they work (the issue in 0.6.2 only affects certain combinations of DBMSen and field options, and as I said, is now fixed in trunk).

comment:8 Changed 7 months ago by impomiaideada

Thank You For This Blog, was added to my bookmarks.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.