Modify ↓
Ticket #447 (closed defect: fixed)
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: |
Description
(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.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

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.