le 02.09.2008 18:33 Michael Bayer a écrit:
> On Sep 2, 2008, at 12:06 PM, Remi Jolin - SysGroup wrote:
>
>   
>> Hello,
>>
>> Here is a small example of my issue (it's Elixir syntax, but I think
>> it's not an Elixir specific issue) :
>> class Rec(Entity):
>>    collection = ManyToOne('Coll')
>>
>> class Coll(Entity):
>>    recs = OneToMany('Rec')
>>
>> r1 = Rec()
>> r2 = Rec()
>> c = Coll(recs=[r1,r2])
>>
>> at that time len(c.recs) == 2
>>
>> if I do something like r1.delete(), I would expect len(c.recs) == 1  
>> but
>> it stays at 2 until the flush(). Am I missing some parameter on the
>> class definitions ?
>> I've tried some "cascade" parameters but they seem to handle the Recs
>> deletion when you delete a Coll.
>>     
>
>
> saying r1.delete() won't automatically update the already-loaded  
> "recs" collection which it's a part of.  You'd instead configure  
> cascade="all, delete-orphan" on "recs", so that the removal of a Rec  
> from c.recs would result in its deletion.  Otherwise, any activity  
> which refreshes "c.recs" after a flush has occured will also do.
>   
So, instead of r1.delete(),  the solution could be (having configured 
cascade="all, delete-orphan" on recs) to do a
r1.collection = None and let the flush() delete it because of the 
cascade rules.
> I'm also not sure if the above is properly associating "recs" with  
> "collection" since SQLA usually needs a "backref" keyword to work this  
> out; I'm not sure what Elixir uses to indicate that.
>   
Elixir handles the backrefs without the need to explicitly define them 
as long as there is no ambiguity.

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