Opened 8 days ago
Closed 30 hours ago
#35997 closed Bug (fixed)
Migrations crash on constraints/indexes with CompositePrimaryKey in fields.
Reported by: | Mariusz Felisiak | Owned by: | Mariusz Felisiak |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
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
I've created a sample project that tries to add UniqueConstraint
with a CompositePrimaryKey
in fields
. Unfortunately, it crashes when trying to migrate:
... File "/django/db/backends/base/schema.py", line 509, in create_model sql, params = self.table_sql(model) ^^^^^^^^^^^^^^^^^^^^^ File "/django/db/backends/base/schema.py", line 283, in table_sql constraint_sqls.extend( File "/django/db/backends/base/schema.py", line 284, in <genexpr> constraint.constraint_sql(model, self) File "/django/db/models/constraints.py", line 512, in constraint_sql return schema_editor._unique_sql( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/django/db/backends/base/schema.py", line 1839, in _unique_sql "columns": ", ".join([self.quote_name(field.column) for field in fields]), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/django/db/backends/base/schema.py", line 207, in quote_name return self.connection.ops.quote_name(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/django/db/backends/postgresql/operations.py", line 190, in quote_name if name.startswith('"') and name.endswith('"'): ^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'startswith'
It's similar to the #35992 but fix is in a completely different place so I decided to create a separate ticket.
Change History (4)
comment:1 by , 8 days ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 30 hours ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Thank you Mariusz!!!