To fix this issue, I have added uniqueness constraint on name and user_id columns of key_pairs table (and removed the extra DB look-up prior to the creation of key pair). However, I am facing a strange issue in SQLAlchemy, due to which, I get a TypeError instead of IntegrityError (sample stack trace http://paste.openstack.org/show/28497/ ) on creating a same named keypair for a user.
This can be overcome by replacing the 'raise' statement by 'raise exc' in _flush( ) method of /usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py.
IMO, this requires a fix in SQLAlchemy session. Can someone please confirm this.
NOTE: Code branch 'master', SQLAlchemy version 0.7.9
To fix this issue, I have added uniqueness constraint on name and user_id columns of key_pairs table (and removed the extra DB look-up prior to the creation of key pair). However, I am facing a strange issue in SQLAlchemy, due to which, I get a TypeError instead of IntegrityError (sample stack trace http:// paste.openstack .org/show/ 28497/ ) on creating a same named keypair for a user.
This can be overcome by replacing the 'raise' statement by 'raise exc' in _flush( ) method of /usr/local/ lib/python2. 7/dist- packages/ sqlalchemy/ orm/session. py.
IMO, this requires a fix in SQLAlchemy session. Can someone please confirm this.
NOTE: Code branch 'master', SQLAlchemy version 0.7.9