Torsten Irländer <torsten.irlaen...@googlemail.com> wrote:

> 
> 
> Am Donnerstag, 12. Februar 2015 18:57:43 UTC+1 schrieb Michael Bayer:
> 
> 
> Torsten Irländer <torsten....@googlemail.com> 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(). 

What’s wrong with the IntegrityException here?  Not specific enough?   I’d 
recommend parsing the string message within it to determine its cause - this is 
a feasible approach that we use widely with openstack.    The exceptions that 
relate to this particular violation will be predictable.     The database does 
a great job of catching this error, so efforts for SQLAlchemy to do the same 
thing would be redundant.


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