mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #25002 -- Used PostgreSQL column type alteration USING clause.
Thanks to Dirk Uys for the report.
This commit is contained in:
@@ -10,6 +10,7 @@ from django.db.models import Model
|
||||
from django.db.models.fields import (
|
||||
AutoField, BigIntegerField, BinaryField, BooleanField, CharField,
|
||||
DateTimeField, IntegerField, PositiveIntegerField, SlugField, TextField,
|
||||
TimeField,
|
||||
)
|
||||
from django.db.models.fields.related import (
|
||||
ForeignKey, ManyToManyField, OneToOneField,
|
||||
@@ -447,6 +448,19 @@ class SchemaTests(TransactionTestCase):
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Note, old_field, new_field, strict=True)
|
||||
|
||||
def test_alter_text_field_to_time_field(self):
|
||||
"""
|
||||
#25002 - Test conversion of text field to time field.
|
||||
"""
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Note)
|
||||
Note.objects.create(info='3:16')
|
||||
old_field = Note._meta.get_field('info')
|
||||
new_field = TimeField(blank=True)
|
||||
new_field.set_attributes_from_name('info')
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Note, old_field, new_field, strict=True)
|
||||
|
||||
@skipIfDBFeature('interprets_empty_strings_as_nulls')
|
||||
def test_alter_textual_field_keep_null_status(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user