Opened 11 years ago
Closed 11 years ago
#21788 closed Uncategorized (wontfix)
Wrong fields order after defer
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Normal | Keywords: | defer models |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
postgresql view:
CREATE VIEW test_view AS SELECT md5(g.*::text) as hash, g.g AS num FROM generate_series(1,4) g;
query result:
|
---|
django model:
class TestView(models.Model): id = models.CharField(primary_key=True, max_length=32, db_column='hash') hash = models.CharField(max_length=32, db_column='hash') num = models.IntegerField(db_column='num') class Meta: db_table = 'test_view'
ipython test:
In [1]: from public_api.models import TestView In [2]: TestView.objects.all()[0].num Out[2]: 1 In [3]: TestView.objects.defer('hash').all()[0].num Out[3]: u'c4ca4238a0b923820dcc509a6f75849b'
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
The problem is almost certainly in having db_column "hash" two times in the model definition. Drop the id field and set the hast field as primary key, or add id column to the view.
You shouldn't use two different fields with the same db column, so closing as wontfix.
Reproduces with Django 1.6 and 1.6.1