Re: [SQLObject] Foreign Key + Constraints?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Sidnei da S. <si...@aw...> - 2003-12-03 18:49:29
|
On Wed, Dec 03, 2003 at 10:28:08AM -0600, Ian Bicking wrote: | On Dec 3, 2003, at 8:59 AM, Sidnei da Silva wrote: | >I just realized that when using ForeignKey, the created table doesn't | >create the foreign key constraints. I would like to add that + the | >'cascade' option to ForeignKey, at least on Postgres. Is there any | >objection on doing so? | | That's fine. It would be nice if MySQL and SQLite could also do | cascades, from the SQL side, i.e., destroySelf() would do the cascade | manually -- at least consider the necessary hooks. Firebird is | probably like Postgres, but I don't know if the syntax matches. Ok, attached is my first try. There's two things I would like to discuss before going on supporting the other databases: First, I'm getting the 'foreign' class via findClass(col.foreignKey), without passing the registry parameter, because AFAICT, I can't get to the SQLObject class from the column. Is that correct? How much trouble can that buy us? :) Second, I think that as I'm getting the 'dependent'[1] classes via findDependencies, It would be simple to pass them into DBConnection.dropTable() so that we can do the cascade the manual way -- by iterating on the result of select() and calling destroySelf() on each object. Does that sound reasonable? [1] I considered 'dependent' a class that has a column which refers to our class on the 'foreignKey' attribute, and also has 'cascade' set to True. Thoughts? -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Counting in binary is just like counting in decimal -- if you are all thumbs. -- Glaser and Way |