Michael Bayer wrote:
> On Feb 8, 2008, at 1:06 PM, Mike Bernson wrote:
>
>   
>> I have a case where a delete was requested and on the commit to the  
>> transaction the delete fails with a
>> integrity error. Problem is a foreign key constraint will not let  
>> the record be delete. Now I have a
>> session which tries to delete this record any time I flush things. I  
>> have rolled back the transaction
>> and now want to stop the session from delete the record.
>>
>> How do I stop the record from being marked as needed to be delete ?
>>     
>
> ooh, we don't have a specific method for that atm.  i think you'd have  
> to expunge() it then put it back in using save_or_update().  you can  
> also probably do the (non-public) equivalent of what an "undelete()"  
> method would do, which is "del session.uow.deleted[obj._state]".  we  
> can add an undelete() which does it too.
>
>
>   
The del session.uow.deleted[obj._state] did not work. I get a exception
but the expunge(), save_or_update() did the trick for me.

Have a undelete() as a public method work be great. I needed to do
this to clean session so other can continue to work with the session
and commit when all the work is done.  This allow me to back out the
bad delete and continue to work.


--~--~---------~--~----~------------~-------~--~----~
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