﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21788	Wrong fields order after defer	anonymous	nobody	"postgresql view:
{{{
#!sql
CREATE VIEW test_view AS
    SELECT md5(g.*::text) as hash,
    g.g AS num FROM generate_series(1,4) g;
}}}

query result:

{{{#!th colspan=2
    {{{#!td
            hash
        }}}
        {{{#!td
            num
        }}}

    {{{#!tr
        {{{#!td
            c4ca4238a0b923820dcc509a6f75849b
        }}}
        {{{#!td
            1
        }}}
    }}}

    {{{#!tr
        {{{#!td
            c81e728d9d4c2f636f067f89cc14862c
        }}}
        {{{#!td
            2
        }}}
    }}}

    {{{#!tr
        {{{#!td
            eccbc87e4b5ce2fe28308fd9f2a7baf3
        }}}
        {{{#!td
            3
        }}}
    }}}

    {{{#!tr
        {{{#!td
            a87ff679a2f3e71d9181a67b7542122c
        }}}
        {{{#!td
            4
        }}}
    }}}
}}}

django model:
{{{
#!python
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:
{{{
#!python

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'
}}}"	Uncategorized	closed	Database layer (models, ORM)	1.6	Normal	wontfix	defer models		Unreviewed	0	0	0	0	0	0
