On Sep 23, 2008, at 10:32 AM, mraer wrote:

>
> Suppose I have two classes of objects which have a reference to each
> other:
>
> Class A:
> b
>
> Class B:
> a
>
> Both references are mandatory so nullable = False
> I use post_update = True in relation function and use_alter = True in
> ForeignKey constructor
>
> After it I try to add two objects:
>
> session = Session()
> a = A()
> b = B()
> a.b = b
> b.a = a
> session.commit()
>
> and catch an exception, because with post_update = True NULL inserted
> in DB, but without post_update= True I can't add two circular
> depending objects.
>
> How to solve with situation to add such pair of objects into DB?

this is only possible if you can configure your database to not  
enforce foreign key constraints until transaction commit time.  Its  
something I have never done myself but I understand it is possible  
with some databases.


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