On Apr 6, 2008, at 3:45 PM, Rick Morrison wrote:

> Is it safe to issue expression-based SQL in the after_insert /  
> after_update methods of a mapper extension using the connection  
> object passed to the extension method?
>

yeah using the Connection to issue SQL is the intended usage of  
after_insert()/after_update(), as long as its not SQL that might  
affect future SQL within the flush itself (like, deleting a row that  
the ORM is going to want to update or delete itself).

> I've got sort of strange requirement of a row with a self- 
> referential FK that needs to be populated on insert, and I'm trying  
> to do it with a single flush() and so reuse the same connection and  
> within the same transaction.

assuming you mean two foreign keys that reference mutual tables, if  
you have relations() set up for these FKs, this is what the  
post_update flag is intended to do for you.   Works best when you put  
post_update on the many-to-one relation() of one of the FKs (it needs  
to be within relation(), not backref()).  this will do the post-UPDATE  
of the newly inserted row.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to