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 20:06:38
|
On Wed, Dec 03, 2003 at 01:25:43PM -0600, Ian Bicking wrote: | I haven't looked at the patch in context yet, but a couple comments... | | >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? | | You mean, delete every instance from the table, then delete the table? | Hmm... dropping a table is a pretty severe thing whatever way you do | it, I'm not sure how important destroySelf is at that point. OTOH, | maybe if you just want to drop without any checks (and presumably | restart your process), you should do it with plain SQL and not the | class method. (E.g., test code will want to do that drop, so it can | start from a consistent state regardless of previous possible | corruption) Ok, I think I misunderstood Postgres here. I though that 'DROP TABLE $tablename CASCADE' would remove the dependant records from the other tables, but that doesn't seem to be true. It changes the dependant tables only when you delete a row, which is good. I didn't had understood that. | >[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. | | I suppose it follows that if the rows are dependent, the table as a | whole is as well. OTOH, that wouldn't occur to me naturally -- it's | something of a corner case. The principle of least surprise would | indicate that we should leave the table around. But that's no good, as | we're inconsistent at that point. I don't follow you 100% here, but I think its related to the above comment. | And what about circular dependencies? These can only happen if NULL is | also allowed in the foreign key, but it does happen. In this case we'd | want to NULL out the one table, remove the first, then maybe remove the | second. I didn't understood this one as well. -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher People are going to scream bloody murder about that. -- Seen on linux-kernel |