summaryrefslogtreecommitdiff
path: root/tests/schema
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2018-06-17 08:51:02 +0200
committerGitHub <noreply@github.com>2018-06-17 08:51:02 +0200
commit6dd4edb1b4f5441c5f543e29395039839c50d10b (patch)
tree8a0ce57b159fe48a0ad485c8fbebf776c3ec653a /tests/schema
parente95008f2411d50929873f634c3e14ebac811fd28 (diff)
downloaddjango-6dd4edb1b4f5441c5f543e29395039839c50d10b.tar.gz
Fixed #29496 -- Fixed crash on Oracle when converting a non-unique field to primary key.
Thanks Tim Graham for the review.
Diffstat (limited to 'tests/schema')
-rw-r--r--tests/schema/models.py1
-rw-r--r--tests/schema/tests.py15
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/schema/models.py b/tests/schema/models.py
index 4512d8bc01..f6bdbd8815 100644
--- a/tests/schema/models.py
+++ b/tests/schema/models.py
@@ -12,6 +12,7 @@ class Author(models.Model):
name = models.CharField(max_length=255)
height = models.PositiveIntegerField(null=True, blank=True)
weight = models.IntegerField(null=True, blank=True)
+ uuid = models.UUIDField(null=True)
class Meta:
apps = new_apps
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index e1bf438ca3..f18b68d04d 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -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.