[SQL-CVS] [ sqlobject-Patches-1539325 ] fromDatabase and delColumn for sqlite
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: SourceForge.net <no...@so...> - 2006-08-15 13:08:32
|
Patches item #1539325, was opened at 2006-08-13 01:42 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1539325&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Arlo Belshee (abelcodemonk) >Assigned to: Oleg Broytmann (phd) Summary: fromDatabase and delColumn for sqlite Initial Comment: This patch implements both fromDatabase and delColumn for sqlite. I added sqlite to the appropriate existing tests; it passes them. fromDatabase is done by parsing the table creation sql from the sqlite_master table. This will work with any sqlite 3, and I think dates back into sqlite 2, but I'm not sure. delColumn is implemented by renaming the table, creating a new table without the one column, then copying all the data over. This is obviously not as efficient as on DBs that support drop column directly, but it works. This implementation of dropColumn does deal correctly with triggers, foreign keys, and indices that reference the table whose column is being dropped. It does not deal correctly with triggers & indices attached directly to the table being altered. Attached items will be lost. Extending the implementation to support re-creating those indices & triggers should be straightforward, but is beyond my needs. You are welcome to do so. Finally, this patch slightly improves the implementation of addColumn for sqlite. It performs a vacuum operation after each column add. See the sqlite documentation for why this is a good idea. ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2006-08-15 17:08 Message: Logged In: YES user_id=4799 Thank you very much! recreateTableWithoutColumn() is an excellent solution! I have some questions about the patch. Why have you added semicolons? I think they are not needed. Why VACUUM after addColumn()? It is more logical to do VACUUM after delColumn(), I suppose. And, BTW, "This command will fail if there is an active transaction." (from the SQLite documentation). Your patch deletes .delColumn(). But I have a number of programs that relies on a presence of the method (even if it's empty). I think you could just call recreateTableWithoutColumn() from delColumn() or raise a warning or an exception. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1539325&group_id=74338 |