I'm sorry to jump in like this but the problem IS elixir-specific.

The operation was a migration from SA to Elixir, and we noticed the
regression when we ran our CRUD and parent elements got delete,
ignoring the ondelete restriction of their children.

In SA, using ondelete="restrict" on any relation works as expected:
an error is raised when you try to commit a deletion that breaks a
forignKeyConstraint. (SA raises IntegrityError).

Now I'm assuming that the ondelete syntax in Elixir is inherited from
SA, or a wrapper for the SA methods.
However, in Elixir's case, No Exception Is Raised. On the contrary,
elixir goes ahead and BYPASSES the foreignkey restrictions that ARE
PRESENT IN THE DB, and deletes the "parent" object forcibly, stranding
dependencies, and generally messing up the DB.


Once again, the expected behaivour is "IntegrityError: you tried to
delete an object that is still being referenced in other tables,
etc..." and NOT "IntegrityError, you tried to set a foreignkey
constraint to None". We do NOT want to update child relations, we want
to BLOCK DELETION IN THE FIRST PLACE.

So this is going in Elixir's bug tracker and NOT SA's because it IS
elixir specific. SA handles it without a hiccup.

On Jul 12, 8:44 am, Gaetan de Menten <[email protected]> wrote:
> On Sun, Jul 11, 2010 at 11:17, chaouche yacine <[email protected]> 
> wrote:
> > --- On Thu, 7/1/10, Diez B. Roggisch <[email protected]> wrote:
>
> >> > There's one problem : the error I'm getting is not on
> >> the foreign key constraint it's on the NOT NULL contraint.
>
> >> This is because SA issues an update to the city, setting
> >> the country to NULL. You can see that if you'd use my code
> >> that set the bind's echo property to True.
>
> >> Now honestly I don't know how to fix this, but this might
> >> help:
>
> >>http://www.sqlalchemy.org/docs/05/mappers.html#using-passive-deletes
>
> >> Passing passive_deletes=True to the OneToMany-relation
> >> might solve the issue of trying to update child-relations.
>
> >> Diez
>
> > Should I consider this a bug and open a ticket for it ?
>
> passive_deletes="all" should do what you want (seems to be only
> available in SA 0.6+). I have never used it myself and I must admit I
> am quite astonished as to how hard it was (how deep in the docs I had
> to dig) to find how to support this (IMO) trivial setup.
>
> If that does not work for you, please ask on SQLAlchemy's mailing
> list, or open a bug in their tracker, as this problem is not specific
> to Elixir.
>
> Hope it helps,
> --
> Gaëtan de Menten

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en.

Reply via email to