Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed isolation of test_rename_table_renames_deferred_sql_references(). #14307

Conversation

felixxm
Copy link
Member

@felixxm felixxm commented Apr 23, 2021

./runtests.py schema.tests.SchemaTests.test_rename_table_renames_deferred_sql_references schema.tests.SchemaTests.test_alter_autofield_pk_to_smallautofield_pk_sequence_owner
Testing against Django installed in '/django/django' with up to 8 processes
Found 2 tests.
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.E
======================================================================
ERROR: test_alter_autofield_pk_to_smallautofield_pk_sequence_owner (schema.tests.SchemaTests)
Converting an implicit PK to SmallAutoField(primary_key=True) should
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "schema_author_pkey1"
DETAIL:  Key (id)=(1) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/django/tests/schema/tests.py", line 1361, in test_alter_autofield_pk_to_smallautofield_pk_sequence_owner
    self.assertIsNotNone(Author.objects.create(name='Bar'))
  File "/django/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/django/django/db/models/query.py", line 453, in create
    obj.save(force_insert=True, using=self.db)
  File "/django/django/db/models/base.py", line 730, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/django/django/db/models/base.py", line 767, in save_base
    updated = self._save_table(
  File "/django/django/db/models/base.py", line 872, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/django/django/db/models/base.py", line 910, in _do_insert
    return manager._insert(
  File "/django/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/django/django/db/models/query.py", line 1289, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/django/django/db/models/sql/compiler.py", line 1427, in execute_sql
    cursor.execute(sql, params)
  File "/django/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/django/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "schema_author_pkey1"
DETAIL:  Key (id)=(1) already exists.


----------------------------------------------------------------------
Ran 2 tests in 0.037s

FAILED (errors=1)
Destroying test database for alias 'default'...

Copy link
Member

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, good.

Interestingly doesn't come up with --parallel=1 OK, yes it does. It must be postgres version… 🤔 Anyhow not something I'm going to worry more about now.

@felixxm felixxm merged commit af609c2 into django:main Apr 26, 2021
@felixxm felixxm deleted the test_rename_table_renames_deferred_sql_references-isolation branch April 26, 2021 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants