#33982 closed Bug (fixed)
TypeError creating DB table SQL with ExclusionConstraint as Statement returned instead of str
Reported by: | James Beith | Owned by: | James Beith |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.1 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Whilst upgrading from Django 4.0.7 to 4.1 we've hit an exception attempting to run our test suit.
We have some models with Postgres ExclusionConstraint
constraints. When these constraints constraint_sql()
is called here as part of building the test database, a Statement
object is returned, instead of a str, and we crash when attempting to join them here
Looks like the ExclusionConstraint
switched to returning a Statement
instead of a str in this PR #15235.
Stacktrace below if it helps.
../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/pytest_django/plugin.py:465: in _django_db_marker request.getfixturevalue("_django_db_helper") src/tests/conftest.py:966: in django_db_setup db_cfg = setup_databases( ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/test/utils.py:220: in setup_databases connection.creation.create_test_db( ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/db/backends/base/creation.py:78: in create_test_db call_command( ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/core/management/__init__.py:198: in call_command return command.execute(*args, **defaults) src/acme-corp/interfaces/common/management_commands.py:50: in execute return super().execute(*args, **options) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/core/management/base.py:448: in execute output = self.handle(*args, **options) src/acme-corp/interfaces/systemjobs/management/commands/migrate.py:31: in handle super().handle(*args, **options) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/pytest_django/fixtures.py:276: in handle return super().handle(*args, **kwargs) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/core/management/base.py:96: in wrapped res = handle_func(*args, **kwargs) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/core/management/commands/migrate.py:314: in handle self.sync_apps(connection, executor.loader.unmigrated_apps) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/core/management/commands/migrate.py:476: in sync_apps editor.create_model(model) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/db/backends/base/schema.py:446: in create_model sql, params = self.table_sql(model) ../../../../.virtualenvs/acme-corp/lib/python3.8/site-packages/django/db/backends/base/schema.py:272: in table_sql "definition": ", ".join( E TypeError: sequence item 9: expected str instance, Statement found
Attachments (1)
Change History (7)
comment:1 by , 2 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 2 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
Thanks for the report! Regression in 0e656c02fe945389246f0c08f51c6db4a0849bd2.