#36092: Composite primary key creates invalid migration when one of its fields
is
inherited
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Release
| blocker
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
(As ever, let me know if this is a known/deferred issue--just trying to
report anything I noticed while taking a look around.)
----
With these models:
{{{#!py
class CoffeeProduct(models.Model):
whole_bean = models.BooleanField()
class SpecialtyCoffeeProduct(CoffeeProduct):
pk = models.CompositePrimaryKey("whole_bean", "varietal")
varietal = models.CharField()
}}}
This migration is generated on sqlite:
{{{#!sql
BEGIN;
--
-- Create model CoffeeProduct
--
CREATE TABLE "appName_coffeeproduct" ("id" integer NOT NULL PRIMARY KEY
AUTOINCREMENT, "whole_bean" bool NOT NULL);
--
-- Create model SpecialtyCoffeeProduct
--
CREATE TABLE "appName_specialtycoffeeproduct" ("coffeeproduct_ptr_id"
bigint NOT NULL UNIQUE REFERENCES "appName_coffeeproduct" ("id")
DEFERRABLE INITIALLY DEFERRED, "varietal" varchar NOT NULL, PRIMARY KEY
("whole_bean", "varietal"));
COMMIT;
}}}
And fails when executed:
{{{
File "/Users/<user>/django/django/db/backends/sqlite3/base.py", line
356, in execute
return super().execute(query)
^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: expressions prohibited in PRIMARY KEY
and UNIQUE constraints
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36092>
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 visit
https://groups.google.com/d/msgid/django-updates/010701945d7295d0-68640e80-c8ef-4f1b-96d7-2cc9b62bf1eb-000000%40eu-central-1.amazonses.com.