1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Refs #30591 -- Adjusted table rebuild for non-pk relationship on SQLite.

The existing code was only accounting for primary key changes and not
all unique key fields that can be referenced.
This commit is contained in:
Simon Charette
2020-04-17 00:54:37 -04:00
committed by Mariusz Felisiak
parent a548280857
commit 5220ca8d8a
2 changed files with 25 additions and 11 deletions

View File

@@ -1341,7 +1341,7 @@ class OperationTests(OperationTestBase):
project_state = self.apply_operations(app_label, ProjectState(), operations=[
migrations.CreateModel('Rider', fields=[
('id', models.AutoField(primary_key=True)),
('code', models.PositiveIntegerField(unique=True)),
('code', models.IntegerField(unique=True)),
]),
migrations.CreateModel('Pony', fields=[
('id', models.AutoField(primary_key=True)),
@@ -1354,6 +1354,18 @@ class OperationTests(OperationTestBase):
models.CharField(max_length=100, unique=True),
)
self.apply_operations(app_label, project_state, operations=[operation])
id_type, id_null = [
(c.type_code, c.null_ok)
for c in self.get_table_description('%s_rider' % app_label)
if c.name == 'code'
][0]
fk_type, fk_null = [
(c.type_code, c.null_ok)
for c in self.get_table_description('%s_pony' % app_label)
if c.name == 'rider_id'
][0]
self.assertEqual(id_type, fk_type)
self.assertEqual(id_null, fk_null)
@skipUnlessDBFeature('supports_foreign_keys')
def test_alter_field_reloads_state_on_fk_with_to_field_related_name_target_type_change(self):