#33982: TypeError creating DB table SQL with ExclusionConstraint as Statement
returned instead of str
-------------------------------------+-------------------------------------
Reporter: James | Owner: nobody
Beith |
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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
[https://github.com/django/django/blob/4.1/django/db/backends/base/schema.py#L266
here] as part of building the test database, a `Statement`
[https://github.com/django/django/blob/4.1/django/contrib/postgres/constraints.py#L116-L127
object is returned], instead of a str, and we crash when attempting to
join them
[https://github.com/django/django/blob/4.1/django/db/backends/base/schema.py#L271-L273
here]
Looks like the `ExclusionConstraint` switched to returning a `Statement`
instead of a str in [https://github.com/django/django/pull/15235 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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33982>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701830c1b7463-444aa174-1b96-47ed-abec-553f27d3760a-000000%40eu-central-1.amazonses.com.