Am Donnerstag, 12. Februar 2015 18:57:43 UTC+1 schrieb Michael Bayer:
>
>
>
> Torsten Irländer <torsten....@googlemail.com <javascript:>> wrote: 
>
> > Hi, 
> > 
> > I have a similar prolem as described in 
> > https://groups.google.com/forum/#!topic/sqlalchemy/OLeCERDZxyk 
> > 
> > I am using the secondary attribute to define the many-to-many 
> relationship between User and Groups. 
> > 
> > Now i want prevent to delete a group if a user is still in the group. 
> Setting the Foreign-Key to "nullable=False" as advised in the post above 
> does not work for me on SQLAlchemy level. It does work when trying to 
> delete the Group directly in Postgres (Error ist raised). I am using no 
> cascading deletes in the relation definition. 
>
> when you say “prevent”, do you mean, session.delete() will silently do 
> nothing, or that an error is raised (or how exactly are these deletes 
> originating)?  If the database is set up with constraints as you describe, 
> then it would raise constraint violations.   Or are you looking for some 
> error message to be raised sooner?
>

Prevent means raise an error which could be excepted (and optionally 
analysed) to show the user some feedback that the deletion of the groups 
can not be done because there are still referencing objects. 
The deletion is done by a session.delete(). 

The constraint seems to work in general as deleting a group on database 
level doesn't work anymore. But when deleting the group by using 
session.delete() the entries in the secondary table are automatically 
removed for the deleted group.

What do you mean by raising an error message sooner? 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to