Modify

Ticket #52 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Implement SQLite alter/rename/drop column via workarounds

Reported by: andrew Owned by: andrew
Priority: minor Milestone: The Future
Component: databaseapi Version: 0.4
Keywords: Cc:

Description

Currently these just raise exceptions in the SQLite commands, but it would be nice to have these "just work", using workarounds like http://grass.osgeo.org/wiki/Sqlite_Drop_Column

Attachments

svn-260-alter-sqlite.patch (8.2 KB) - added by angri 5 years ago.
patch which can do the trick

Change History

comment:1 Changed 5 years ago by andrew

  • Milestone set to 0.4

comment:2 Changed 5 years ago by andrew

  • Status changed from new to accepted

comment:3 Changed 5 years ago by andrew

  • Status changed from accepted to assigned

comment:4 Changed 5 years ago by andrew

  • Milestone changed from 0.4 to The Future

Looks like this will require manually parsing the content of sqlite_master, which is not a feature I'm willing to roll in to 0.4 at this point. Pushing to The Future.

At this rate, 0.5 will be the parsing-a-plenty release.

comment:5 Changed 5 years ago by Robert <trebor74hr@…>

What is suggested on page http://grass.osgeo.org/wiki/Sqlite_Drop_Column
is very similar what is already done and obviously works in django-evolution. Place is db.sqlite3.EvolutionOperations?.delete_column i.e.
http://code.google.com/p/django-evolution/source/browse/trunk/django_evolution/db/sqlite3.py#9.

Basically:

  • dump data to new temp table without the column
  • drop table
  • create table without the column
  • copy data from temp table
  • drop temp table

Why not reuse the logic/code and enable this. Btw. this type of scenario is base for all kind of implementations where db engine doesn't support SQL DDL command (alter table, alter column, rename column, drop column, add column, etc.). Later most of unsupported operations for various engines could be implemented in the same manner.

comment:6 Changed 5 years ago by andrew

  • Version set to 0.4

The major problem with implementing this so far has, in fact, been in determining the schema of the new temp table - previously, it would have involved parsing of the only data SQLite gives you about tables (their CREATE TABLE statement).

Now, someone's working on doing it using the ORM. Updates to follow.

Changed 5 years ago by angri

patch which can do the trick

comment:7 Changed 5 years ago by angri

It was not tested with every column type supported by django. But I think it is a good start and it may be usefull for somebody.

--
Anton Gritsay
anton@…

comment:8 Changed 5 years ago by diegobz@…

Any news about this feature?

comment:9 Changed 5 years ago by andrew

It's being worked on in a separate fork; rename_column was merged in a while ago, others weren't ready.

comment:10 Changed 5 years ago by Velmont

So it'll get in the next release?

comment:11 Changed 5 years ago by andrew

Hopefully. Can't say much more just yet.

comment:12 Changed 4 years ago by olau@…

Hi, just hit this page via Google. Actually I just did this by hand - instead of creating a tmp table, you can just rename the old table to tmp and use that as source.

comment:13 Changed 4 years ago by andrew

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

0.7 fixes this.

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.