#28391 closed Bug (fixed)

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

Reported by: felixxm Owned by: felixxm
Component: Database layer (models, ORM) Version: master
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 felixxm 12 months ago.

Download all attachments as: .zip

Change History (4)

Changed 12 months ago by felixxm

Attachment: 28391.diff added

comment:1 Changed 12 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:2 Changed 12 months ago by felixxm

Has patch: set

comment:3 Changed 12 months 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