On 6/19/14, 8:02 PM, Jonathan Vanasco wrote: > Due to a business requirement and an odd distribution of data / > performance issue, my database currently has 2 tables which are > inter-related : > > class Relationship(): > id_a = int ,references table_a(id) > id_b = int, references table_b(id) > relationship_id = int, references relationships(id) > > class RelationshipFoo(): > id_a = int ,references table_a(id) > id_b = int, references table_b(id) > display_name = varchar(64) > > 97% of the relationships in the database are the 'Relationship' type. > This table is basically readonly. > 3%, are 'RelationshipFoo', which have an editable 'name'. This table > is readwrite, as these are often edited. > > There was a noticeable gain moving from 1 to 2 tables. So be it. > > Here's my issue. > > If I delete a RelationshipFoo, it requires me to also delete a > corresponding `Relationship( id_a=foo.id_a , id_b=foo.id_b, > relationship_id=5 )` > > For stuff like this, I would normally just use the engine directly. > > However, this particular operation happens in a huge block of content > management operations... and I don't want to emit any sql / `flush` to > the database yet. there's still handful of operations that could > trigger a rollback. > > Aside from preloading a `Relationship` object and then marking it for > deletion in the session, is there any trick/technique I can use to > create a "deletion request" for the `Relationship` object that won't > emit sql until I "flush" ? cascading foreign key is one way. or before_delete() / after_delete() event, just emit the DELETE straight on the connection, no need to load Relationship.
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.