﻿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
27825	Document that models don't cast field values to the same type that's retrieved from the database	Oleg Belousov	nobody	"My experience is that when using the `Constructor` (`ORM`) class by references with Django `1.10.5`
There might be some inconsistencies in the data (i.e. the attributes of the created object may get the type of the input data instead of the casted type of the ORM object property) 

Example:
 `models`

{{{
 class Payment(models.Model):
     amount_cash = models.DecimalField()
}}}
 

`some_test.py` - `object.create` 

{{{
Class SomeTestCase: 
     def generate_orm_obj(self, _constructor, base_data=None, modifiers=None):
           objs = [] 
          if not base_data: 
               base_data = {'amount_case': 123.00} 
               for modifier in modifiers: 
                    actual_data = deepcopy(base_data) 
                    actual_data.update(modifier) 
                     _obj = _constructor.objects.create(**actual_data) 
                    print(type(_obj.amount_cash)) # Decimal                                                                       
               return objs
}}}

 `some_test.py` - `Constructor()` 
 
{{{
Class SomeTestCase: 
    def generate_orm_obj(self, _constructor, base_data=None, modifiers=None): 
                objs = [] 
                if not base_data:
                     base_data = {'amount_case': 123.00}
                     for modifier in modifiers: 
                        actual_data = deepcopy(base_data) 
                        actual_data.update(modifier) 
                         _obj = _constructor(**actual_data)
                        print(type(_obj.amount_cash)) # Float 
                    objs.append(_obj) return objs
}}}
"	Cleanup/optimization	new	Documentation	1.10	Normal		ORM		Accepted	0	0	0	0	0	0
