Opened 7 years ago

Closed 7 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

Description

Correct behavior, e.g. (based on db_functions/test_cast.py):

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

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

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

by Mariusz Felisiak, 7 years ago

Attachment: 28391.diff added

comment:1 by Tim Graham, 7 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Mariusz Felisiak, 7 years ago

Has patch: set

comment:3 by GitHub <noreply@…>, 7 years ago

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