#13516 closed (fixed)
sqlall silently ignores any fields that are a subclass of AutoField
Reported by: | Michael Manfre | Owned by: | Michael Manfre |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A field that is a subclass of AutoField will be silently ignored in the output of manage.py sqlall
An app with a models.py containing:
class MyAutoField(models.AutoField): pass class TestModel(models.Model): id = MyAutoField(primary_key=True, db_column='SomeID')
will output the below from sqlall for sqlite3.
BEGIN; CREATE TABLE "testapp_testmodel" ( ) ; COMMIT;
sqlall works as expected when models.AutoField is used instead of MyAutoField.
Attachments (1)
Change History (8)
comment:1 by , 15 years ago
milestone: | 1.2 |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | SVN → 1.1 |
comment:2 by , 14 years ago
Owner: | changed from | to
---|
by , 14 years ago
Attachment: | django-ticket13516-v1.2.diff added |
---|
Fix Django 1.2 to allow subclassing AutoField
comment:3 by , 14 years ago
Has patch: | set |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Added patch for Django v1.2 (up to r13444).
There is also the workaround of overriding get_internal_type in the subclass to return "AutoField" instead of self.class.name (from class Field). The issue is that the internal type is passed to the database backends so they can map the field to a database type.
class MyAutoField(models.AutoField): def get_internal_type(self): return "AutoField"
comment:4 by , 14 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:5 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Verified, but not 1.2 critical - this problem has existed for a while.