mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #29496 -- Fixed crash on Oracle when converting a non-unique field to primary key.
Thanks Tim Graham for the review.
This commit is contained in:
parent
e95008f241
commit
6dd4edb1b4
4 changed files with 32 additions and 6 deletions
|
@ -12,7 +12,7 @@ from django.db.models.deletion import CASCADE, PROTECT
|
|||
from django.db.models.fields import (
|
||||
AutoField, BigAutoField, BigIntegerField, BinaryField, BooleanField,
|
||||
CharField, DateField, DateTimeField, IntegerField, PositiveIntegerField,
|
||||
SlugField, TextField, TimeField,
|
||||
SlugField, TextField, TimeField, UUIDField,
|
||||
)
|
||||
from django.db.models.fields.related import (
|
||||
ForeignKey, ForeignObject, ManyToManyField, OneToOneField,
|
||||
|
@ -603,6 +603,19 @@ class SchemaTests(TransactionTestCase):
|
|||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Author, old_field, new_field, strict=True)
|
||||
|
||||
def test_alter_not_unique_field_to_primary_key(self):
|
||||
# Create the table.
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Author)
|
||||
# Change UUIDField to primary key.
|
||||
old_field = Author._meta.get_field('uuid')
|
||||
new_field = UUIDField(primary_key=True)
|
||||
new_field.set_attributes_from_name('uuid')
|
||||
new_field.model = Author
|
||||
with connection.schema_editor() as editor:
|
||||
editor.remove_field(Author, Author._meta.get_field('id'))
|
||||
editor.alter_field(Author, old_field, new_field, strict=True)
|
||||
|
||||
def test_alter_text_field(self):
|
||||
# Regression for "BLOB/TEXT column 'info' can't have a default value")
|
||||
# on MySQL.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue