Hi,

I wrote (the attached) script to reproduce the issue, however, it seems to be 
working fine (i.e it returns the right exception). After a detailed check of my 
application source 
(https://github.com/openstack/nova/blob/master/nova/db/sqlalchemy/api.py#L1981 
), I found that adding a session.begin( ) call before calling the method save( 
) (which internally does a session.add( ) and session.flush( )),  resolves the 
issue. Does this fix look correct?


Thanks & Regards,
Unmesh Gurjar | Lead Engineer | NTT DATA Global Technology Services Private 
Limited | w. +91.20.6604.1500 x 379 | m. +91.982.324.7631 | 
unmesh.gur...@nttdata.com<mailto:unmesh.gur...@nttdata.com> | Learn more at 
nttdata.com/americas

From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On 
Behalf Of Michael Bayer
Sent: Friday, January 04, 2013 10:12 PM
To: sqlalchemy@googlegroups.com
Subject: Re: [sqlalchemy] Query about exception being raised on violating 
uniqueness constraint

Would need much more detail here including a full stack trace, what line you're 
referring to in _flush(), and preferably code which reproduces the error you're 
seeing.


On Jan 4, 2013, at 1:55 AM, Gurjar, Unmesh wrote:


Hi,

I have installed SQLAlchemy 0.7.9 (backend - MySQL, Python 2.7). I have a 
defined a table having a uniqueness constraint. On inserting a record which 
violates this constraint, my application gets a 'TypeError' exception instead 
of 'IntegrityError'.

After debugging the issue, I found that it can be resolved by replacing the 
'raise' statement by 'raise exc' in _flush( ) method of 
sqlalchemy/orm/session.py. Can someone please confirm if this should be the 
expected behavior?

Thanks & Regards,
Unmesh Gurjar.


______________________________________________________________________
Disclaimer:This email and any attachments are sent in strictest confidence for 
the sole use of the addressee and may contain legally privileged, confidential, 
and proprietary data. If you are not the intended recipient, please advise the 
sender by replying promptly to this email and then delete and destroy this 
email and any attachments without any further use, copying or forwarding

--
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<mailto:sqlalchemy@googlegroups.com>.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

--
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<mailto:sqlalchemy@googlegroups.com>.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

______________________________________________________________________
Disclaimer:This email and any attachments are sent in strictest confidence for 
the sole use of the addressee and may contain legally privileged, confidential, 
and proprietary data.  If you are not the intended recipient, please advise the 
sender by replying promptly to this email and then delete and destroy this 
email and any attachments without any further use, copying or forwarding

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Attachment: integrity_error_test.py
Description: integrity_error_test.py

Reply via email to