UUIDField ignores primary_key=False when generating migrations or SQL
xjlin0 opened this issue · 1 comments
xjlin0 commented
Problem
UUIDField with the option of primary_key=False
got reverted to primary_key=True
in generated migrations or SQL.
Environment
- Django Model Utils version: 4.2.0
- Django version: 3.2.11
- Python version: cPython 3.9.10
- Other libraries used, if any: with Cookie cutter Django version 2021-10-26
Code examples
Including a UUIDField with primary_key=False
in a model:
test = model_utils.fields.UUIDField(primary_key=False, default=uuid.uuid4, editable=False, serialize=False)
Surprisingly, when running migration it becomes primary_key=True
:
field=model_utils.fields.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, serialize=False)
as well as generated SQL:
CREATE TABLE table_name ("test" uuid NOT NULL PRIMARY KEY ....
If the model already got primary key column, it's a headache to find workaround.
Expectation
UUIDField with the option of primary_key=False
should keep primary_key=False
in generated migrations or SQL.
timjnz commented
Can confirm - I'm getting the same problem