[Django] #35325: CharField max_length ignored

8 views
Skip to first unread message

Django

unread,
Mar 22, 2024, 8:20:12 AM3/22/24
to django-...@googlegroups.com
#35325: CharField max_length ignored
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
Aristotelis Mikropoulos |
Type: Bug | Status: new
Component: Database | Version: 5.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In a vanilla project and app (all default settings, nothing changed),
trying to create a model record with a CharField longer than what is
defined, works (no exception raised, no truncation):

{{{
# models.py
from django.db import models

class Foo(models.Model):
name = models.CharField(max_length=5)
}}}

{{{
$ python manage.py shell
>>> from foo.models import Foo
>>> Foo.objects.create(name='abcdefghijk')
<Foo: Foo object (1)>
>>> f = Foo.objects.first()
>>> f
<Foo: Foo object (1)>
>>> f.name
'abcdefghijk'
}}}

Maybe I am missing something, or maybe that's just sqlite behavior, but
shouldn't some exception be raised?

Ubuntu 22.04
Python 3.10.12
Django 5.0.3
DB engine django.db.backends.sqlite3 (default)
--
Ticket URL: <https://code.djangoproject.com/ticket/35325>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 22, 2024, 8:22:38 AM3/22/24
to django-...@googlegroups.com
#35325: CharField max_length ignored
-------------------------------------+-------------------------------------
Reporter: Aristotelis | Owner: nobody
Mikropoulos |
Type: Bug | Status: closed
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: => duplicate
* status: new => closed

Comment:

Duplicate of #21471.
--
Ticket URL: <https://code.djangoproject.com/ticket/35325#comment:1>
Reply all
Reply to author
Forward
0 new messages