| 133 | |
| 134 | # Test for bug 11900, better error handling for commits during commit_on_success blocks. |
| 135 | # The bug has only been verified to occur using the psycopg2 backend, though the fix is generally a good idea. |
| 136 | pgsql_backends = ('django.db.backends.postgresql_psycopg2', 'postgresql_psycopg2',) |
| 137 | if building_docs or settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] in pgsql_backends: |
| 138 | __test__['API_TESTS'] += """ |
| 139 | >>> def execute_bad_sql(): |
| 140 | ... cursor = connection.cursor() |
| 141 | ... cursor.execute('INSERT INTO auth_user_groups (user_id, group_id) VALUES (1000000, 1000000);') |
| 142 | ... transaction.set_dirty() |
| 143 | ... |
| 144 | >>> execute_bad_sql = transaction.commit_on_success(execute_bad_sql) |
| 145 | >>> execute_bad_sql() |
| 146 | Traceback (most recent call last): |
| 147 | ... |
| 148 | IntegrityError: insert or update on table "auth_user_groups" violates foreign key constraint "auth_user_groups_user_id_fkey" |
| 149 | DETAIL: Key (user_id)=(1000000) is not present in table "auth_user". |
| 150 | """ |
| 151 | No newline at end of file |