Opened 4 years ago
Closed 3 years ago
#33464 closed Cleanup/optimization (fixed)
Resolve output_field when combining numeric expressions with MOD operator.
| Reported by: | gsinghkular | Owned by: | David Wobrock |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 3.2 |
| Severity: | Normal | Keywords: | |
| Cc: | David Wobrock | 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
When writing a Django expression for a query that does MOD, if the types of the query are different (Decimal and Integer), it doesn't resolve the result to a Decimal type, like it does for other mathematical operators.
Change History (9)
comment:1 by , 4 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
| Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 4 years ago
| Resolution: | duplicate |
|---|---|
| Status: | closed → new |
I'm pretty sure the changes committed as part of #33397, while closely related, doesn't actually address this case. I think it's best to handle this as a separate ticket.
comment:3 by , 4 years ago
| Summary: | Django db expressions doesn't combine MOD → Resolve output_field when combining numeric expressions with MOD operator. |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
follow-up: 5 comment:4 by , 3 years ago
| Cc: | added |
|---|
Hasn't this been addressed by https://github.com/django/django/pull/15271/files#diff-359ab56295cce36b9597e1d65185f695f271955617b40f43df58ce3fe76fd0c8R492?
Removing the marked line will make expressions.tests.ExpressionOperatorTests.test_lefthand_modulo_null fail with a Cannot infer type of '%%' expression involving these types: IntegerField, IntegerField. You must set output_field.
Which sounds pretty close to what is described in the issue here.
Or what am I missing? :)
comment:5 by , 3 years ago
Replying to David Wobrock:
Hasn't this been addressed by https://github.com/django/django/pull/15271/files#diff-359ab56295cce36b9597e1d65185f695f271955617b40f43df58ce3fe76fd0c8R492?
No, this issue is for mixed numeric types, e.g. DecimalField and IntegerField.
comment:7 by , 3 years ago
| Patch needs improvement: | set |
|---|
comment:8 by , 3 years ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Duplicate of #33397.