Opened 4 years ago

Closed 4 years ago

#31987 closed Bug (fixed)

Cast() crashes with DurationField on MySQL.

Reported by: Petr Čermák Owned by: Petr Čermák
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords: mysql
Cc: 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

It is not possible to use:

django.db.models.functions.Cast(x, output_field=DurationField())

because it generated CAST(xxx AS bigint) which is not valid MySQL syntax.

Change History (6)

comment:1 by Simon Charette, 4 years ago

Needs tests: set
Patch needs improvement: set

Haven't reproduced but you'll need a regression test to demonstrate the issue this addresses.

comment:2 by Mariusz Felisiak, 4 years ago

Owner: changed from nobody to Petr Čermák
Status: newassigned
Summary: Cast data type for DurationField is mising for MySQLCast() crashes with DurationField on MySQL.
Triage Stage: UnreviewedAccepted

comment:3 by Mariusz Felisiak, 4 years ago

Summary: Cast() crashes with DurationField on MySQL.Cast() crashes with DurationField on MySQL and Oracle.

comment:4 by Simon Charette, 4 years ago

Needs tests: unset
Patch needs improvement: unset

Submitted test looks great, suggested a way to reduce without involving multiple objects and aggregation.

comment:5 by Mariusz Felisiak, 4 years ago

Summary: Cast() crashes with DurationField on MySQL and Oracle.Cast() crashes with DurationField on MySQL.
Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In fc144607:

Fixed #31987 -- Fixed Cast() with DurationField on MySQL.

Note: See TracTickets for help on using tickets.
Back to Top