| 13 | ============= |
| 14 | I am using Postgres. |
| 15 | |
| 16 | {{{ |
| 17 | SomeModel.objects.create(some_field_of_type_int=2) |
| 18 | sm = SomeModel.objects.annotate(x=F("some_field_of_type_int") / Decimal(3.0)).get() |
| 19 | sm.x # returns 0 |
| 20 | }}} |
| 21 | |
| 22 | It will render Decimal of 3.0 to the query as 3 (INT). Because str(...) from Decimal(3.0) returns 3. (See cases at description) |
| 23 | At python is not a problem, but at database it is, cus it breaks types. Calculation of two INTs at postgres, will return int as well, which is in this case 0, instead of 0.6666, which database would produce, if Django would render 3.0 instead of 3. |
| 24 | |
| 25 | Therefore, Django will return Decimal('0'), which I consider as Bug. This is not what anyone suppose to get. |
| 26 | ============= |