On Sun, Jun 21, 2009 at 09:12, yoav glazner<[email protected]> wrote:
> I have a problem using the global session auto-commit: > > <code> > session.configure(autocommit=True,autoflush=True) > > # number is primary key and the table already have a project number 666 > Project(name='pop',number=666) > > Project.query.all() #boom > </code> > > as you see, i get the exception only in > "Project.query.all()" > > is there a way to get the exception in > "Project(name='pop',number=666)"? Sorry for the very late answer. I hope it is still relevant. There is no way to do that that I know of. You can't know the constraint will be violated unless you hit the database, and you don't want to hit the database everytime you instanciate a new object. What I would advice in this case is to force a flush in that case (even if the session is autoflushed) through: session.flush() By the way, I would personally advice against using both autocommit and autoflush at the same time. -- Gaëtan de Menten http://openhex.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
