Ticket #447 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

added columns get wrong default value in SQLite

Reported by: carl@… Owned by: andrew
Priority: major Milestone: 0.7.1
Component: databaseapi Version: 0.7
Keywords: Cc:


(I'm positive I've seen this discussed before somewhere, but for the life of me can't find a ticket in Trac, so...)

If you add a column in SQLite, the column gets its own name set as the default value for all existing rows. Which is obviously wrong.

The reason is that the current implementation of sqlite3.DatabaseOperations?._copy_table doesn't correctly handle fields that exist in the destination (new) table but not in the source (old) table; it naively tries to select those fields from the old table, but since the field doesn't exist there, the field name itself is selected as a string.

Change History

comment:1 Changed 6 years ago by carl@…

Fix for this (with added test) is in my branch: http://bitbucket.org/carljm/south/changeset/684edc7c93ef

With this fix, all tests pass on SQLite3, Postgresql_psycopg2, and Mysql. With the test addition and not the code fix, add_column test fails on Sqlite3.

comment:2 Changed 6 years ago by andrew

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

Hrm, I remember it being discussed before, but I think that discussion found a different bug (the double PRIMARY KEY one),

Pulled, and looks good to me.

Note: See TracTickets for help on using tickets.