Modify

Ticket #54 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

alter_column has null-ness swapped

Reported by: agkish@… Owned by: andrew
Priority: major Milestone:
Component: databaseapi Version:
Keywords: Cc:

Description

Looking in alter_column in generic.py, the set_null and drop_null are kinda semantically backwards. The sql.appends are swapped though, so it works out ok.

    alter_string_set_null = 'ALTER COLUMN %(column)s SET NOT NULL'
    alter_string_drop_null = 'ALTER COLUMN %(column)s DROP NOT NULL'
...
        if field.null:
            sqls.append((self.alter_string_drop_null % params, []))
        else:
            sqls.append((self.alter_string_set_null % params, []))

Then in mysql.py, the strings actually do what they say they do. This makes mysql columns the opposite of what they're supposed to be.

    alter_string_set_null = 'MODIFY %(column)s %(type)s NULL;'
    alter_string_drop_null = 'MODIFY %(column)s %(type)s NOT NULL;'

I've included a patch along with a test that shows the problem. In the patch, I swapped the stuff in generic.py to be what I perceive to be sane, and then the MySQL stuff starts working.

Attachments

alter_column_null.diff (4.7 KB) - added by anonymous 5 years ago.
alter_column_null.2.diff (5.6 KB) - added by anonymous 5 years ago.
alter_column_null.2.2.diff (5.3 KB) - added by anonymous 5 years ago.

Change History

Changed 5 years ago by anonymous

comment:1 Changed 5 years ago by andrew

  • Status changed from new to assigned

The large amounts of tracebacks seem to indicate you've forgotten the tests' 0003_alter_spam migration...

Changed 5 years ago by anonymous

Changed 5 years ago by anonymous

comment:2 Changed 5 years ago by anonymous

Whoops. alter_column_null.2.2.diff should be correct.

comment:3 Changed 5 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to fixed

OK, fixed in [103] and [104]. I had to rewrite null_ok to use basic SQL; the DBAPI introspection appears to consist of only fail when applied to Postgres databases.

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.