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.
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---