Which was the error I posted to ask about in the first place ;-)

Writing a session extension for this problem seems like using a very
very very large hammer, since I only need to trigger my 'manual
cascade' in a particular circumstance.

I'm hoping Mike or one of the devs might have advice on how this
situation is meant to be handled ?

2008/11/27  <[EMAIL PROTECTED]>:
>
> i've modified all relations to be all,delete-orphan and now it does
> add them all - as your scoped session does - and then complains:
>
> Deleting owner
> BEGIN
> DELETE FROM friendship WHERE friendship.id = %(id)s
>  [{'id': 1L}, {'id': 2L}]
> DELETE FROM owner WHERE owner.id = %(id)s
>  {'id': 1L}
> DELETE FROM dog WHERE dog.id = %(id)s
>  [{'id': 1}, {'id': 2}]
> ROLLBACK
> Traceback (most recent call last):
>  File "f.py", line 138, in <module>
>    session.flush()
> ...
>    raise exc.DBAPIError.instance(statement, parameters, e,
> connection_invalidated=is_disconnect)
> sqlalchemy.exc.IntegrityError: (IntegrityError) update or delete on
> table "dog" violates foreign key constraint "friendship_dog_id_fkey"
> on table "friendship"
> DETAIL:  Key (id)=(1) is still referenced from table "friendship".
>  'DELETE FROM dog WHERE dog.id = %(id)s' [{'id': 1}, {'id': 2}]
>
> well... u have other friendships referencing that same dog/s.
>
> so i tried this and that and if the friendship.dog has no cascades at
> all (i.e. just default), then all seems ok - owner and friendships
> deleted, dogs not.
> i guess u want when 2nd owner gets deleted to delete the orphan dogs?
> it's not in the src...
>
> maybe a better testcase would be of help - asserting whats in db and
> what should not be, before and after.
>
> back on the initial question, mapperExt come to play too late in
> session. u may try sessionExt hooks... or other/earlier mapperExt
> hook... eventualy.
>
> svil
>
> On Thursday 27 November 2008 10:30:04 David Harrison wrote:
>> Postgres is the intended deployment platform so it really does need
>> to work on Postgres, that said last time I dug into this I found
>> that SQLite is less strict on enforcing key constraints where
>> Postgres isn't, so technically Postgres is right to complain.
>>
>> 2008/11/27  <[EMAIL PROTECTED]>:
>> > and what that shoud do? attached is a changed version... do see
>> > if that's what u want (it's sqlite, with plain session).
>> > the only real change is cascade=all,delete-orphan on
>> > house.owners... but i just unintentionaly guessed it.
>> >
>> > On Thursday 27 November 2008 09:51:38 David Harrison wrote:
>> >> So this is actually a follow on from a question I posed quite a
>> >> while back now:
>> >>
>> >> http://groups.google.com/group/sqlalchemy/browse_thread/thread/4
>> >>530
>> >> dffffd3f5585/eb4638599b02577d?lnk=gst&q=Postgres+cascade+error#e
>> >>b463 8599b02577d
>> >>
>> >> So my approach to solving this problem was to use a
>> >> MapperExtension, but it's giving me the error that I originally
>> >> posted in this thread.
>
> >
>

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