コード例 #1
0
 def _test_impl(self, engine_name, error_msg):
     try:
         error = sqlalchemy.exc.IntegrityError('test', 'test', error_msg)
         session._raise_if_duplicate_entry_error(error, engine_name)
     except exception.DBDuplicateEntry as e:
         self.assertEqual(e.columns, ['a', 'b'])
     else:
         self.fail('DBDuplicateEntry was not raised')
コード例 #2
0
 def test_ibm_db_sa_raise_if_duplicate_entry_error_no_match(self):
     # Tests that the session._raise_if_duplicate_entry_error method
     # does not raise a DBDuplicateEntry exception when it's not a matching
     # integrity error.
     statement = ('ALTER TABLE instance_types ADD CONSTRAINT '
                  'uniq_name_x_deleted UNIQUE (name, deleted)')
     params = None
     orig = sqla_exc.SQLAlchemyError(
         'SQL0542N  The column named "NAME" cannot be a column of a '
         'primary key or unique key constraint because it can contain null '
         'values.')
     integrity_error = sqla_exc.IntegrityError(statement, params, orig)
     session._raise_if_duplicate_entry_error(integrity_error, 'ibm_db_sa')
コード例 #3
0
    def test_unsupported_backend_returns_none(self):
        error = sqlalchemy.exc.IntegrityError('test', 'test', 'test')
        rv = session._raise_if_duplicate_entry_error('oracle', error)

        self.assertIsNone(rv)