On Jun 5, 2007, at 6:39 AM, lingo wrote:

>
> I'm using Sqlalchemy with PostgreSQL in a project.
>
> Some of the relations (foreign keys) in the database (postgresql) have
> ON_DELETE=RESTRICT which should prevent parent objects with existing
> child objects from being deleted (tested, works in pg client).

ON_DELETE=RESTRICT is the virtually the same as the default setting  
of "NO ACTION" in Postgres.  SQLAlchemy's ORM organizes SQL  
operations according to foreign key dependency and no errors should  
occur.

>
> An example of my current mappings:
> Child_table = sa.Table('Child', metadata, autoload=True)
> Parent_table = sa.Table('Parent', metadata, autoload=True)
>
> orm.mapper(Parent,Parent_table, properties={
>   'Children' :
> relation(Child,primaryjoin=Parent_table.c.id==Child_table.c.parent_id,
> backref=backref("Parent", remote_side=[Parent_table.c.id]))
>   }
> )

I notice you are specifying primary join conditions manually.  these  
should pick up automatically based on the foreign keys present in  
child/parent table.  is it possible that the foreign keys are not  
being detected in the autoload=True operation ?  try spelling out the  
tables manually not using autoload=True.




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