#31064: Migration doesn't detect precision changes in fields that ManyToMany 
points
to.
-----------------------------+------------------------------------
     Reporter:  zapililirad  |                    Owner:  Dart
         Type:  Bug          |                   Status:  assigned
    Component:  Migrations   |                  Version:  master
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------

Comment (by Simon Charette):

 Sanskar it's possible the issue is only present on SQLite because it deals
 with column alterations in a different way since it doesn't support `ALTER
 TABLE`.

 The idea is that is you have the follow models

 {{{#!python
 class Author(models.Model):
     pass

 class Book(models.Model):
     isbn = models.CharField(max_length=10, primary_key=True)
     authors = models.ManyToManyField(Author)
 }}}

 Django will automatically created a `trough` model

 {{{#!python
 # Automatically created by Django
 class Book_Authors(models.Model):
     book= models.ForeignKey(Book)  # This is a
 models.CharField(max_length=10) referring to Book.isbn
     author = models.ForeignKey(Author)
 }}}

 Now the reported issue is that if you If you change `Book.isbn.max_length`
 to 13 the `Book_Authors.book` field in the intermediary table that backs
 the `Book.authors` many-to-many relationship currently doesn't change to
 `max_length=13`.

 
[https://github.com/django/django/blob/a4881f5e5d7ee38b7e83301331a0b4962845ef8a/django/db/backends/base/schema.py#L757
 The re-pointing logic currently lives] in
 `BaseDatabaseSchemaEditor._alter_field` but it's possible that it's only
 
[https://github.com/django/django/blob/a4881f5e5d7ee38b7e83301331a0b4962845ef8a/django/db/backends/sqlite3/schema.py#L348-L365
 an issue with SQLite schema editor].

 By a quick glance at the code it looks like it could be a SQLite only
 issue due to
 
[https://github.com/django/django/blob/a4881f5e5d7ee38b7e83301331a0b4962845ef8a/django/db/backends/sqlite3/schema.py#L364
 this particular line].

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31064#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.157e702251d3b05395e99a06f7595c05%40djangoproject.com.

Reply via email to