Modify

Ticket #51 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Sqlite3 does not support dropping of columns

Reported by: rdreinet@… Owned by: andrew
Priority: major Milestone:
Component: databaseapi Version: 0.6-pre
Keywords: sqlite3, alter, column, drop Cc:

Description

Regarding http://www.sqlite.org/lang_altertable.html Sqlite3 does not support dropping or renaming of columns. Nevertheless South tries to and fails:

 > document: 0003_docfolder
   = ALTER TABLE "document_documentfolder" DROP COLUMN "is_public" CASCADE; []
**snip**
  File "/home/pascal/projects/march/lib/python2.5/site-packages/South-0.3-py2.5.egg/south/db/generic.py", line 333, in delete_column
    self.execute('ALTER TABLE %s DROP COLUMN %s CASCADE;' % params, [])
  File "/home/pascal/projects/march/lib/python2.5/site-packages/South-0.3-py2.5.egg/south/db/generic.py", line 33, in execute
    cursor.execute(sql, params)
  File "/home/pascal/projects/march/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/backends/sqlite3/base.py", line 168, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: near "DROP": syntax error

I don't know how other migration frameworks handle this, but at least the delete_column-method should be implemented and throw a custom error message or something like that.

Attachments

Change History

comment:1 Changed 6 years ago by rdreinet@…

I had a look at south.db.sqlite3 and noticed that the mentioned exceptions are already there except for delete_column.
I also found a workaround that seems quite complex, though:

http://grass.osgeo.org/wiki/Sqlite_Drop_Column

comment:2 Changed 6 years ago by andrew

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

Fixed in [100], by just adding a nice error, like we have for rename/alter_column

I'll need to see if other frameworks work around this better. We can probably implement analogous operations, using table renaming (make a new table, copy data across, delete old, rename table), but I'll need to see how necessary/stable that is. It would be nice to fake those three opers.

comment:3 Changed 6 years ago by andrew

Also see #52, which will be the ticket for making it "just work".

View

Add a comment

Modify Ticket

Action
as closed
Author


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

 
Note: See TracTickets for help on using tickets.