Opened 6 years ago

Closed 6 years ago

#28391 closed Bug (fixed)

Cast doesn't take into account CharField's max_length on MySQL.

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: Cast
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Correct behavior, e.g. (based on db_functions/

>>> Author.objects.create(name='Bob', age=1111)
>>> numbers = Author.objects.annotate(cast_string=Cast('age', models.CharField(max_length=3)))
>>> numbers.get().cast_string

on MySQL it returns 1111 (related with #28371).

Attachments (1)

28391.diff (928 bytes) - added by Mariusz Felisiak 6 years ago.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by Mariusz Felisiak

Attachment: 28391.diff added

comment:1 Changed 6 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Mariusz Felisiak

Has patch: set

comment:3 Changed 6 years ago by GitHub <noreply@…>

Resolution: fixed
Status: assignedclosed

In 776cee9:

Fixed #28391 -- Fixed Cast() with CharField and max_length on MySQL.

Thanks Tim Graham for the review.

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