Opened 20 months ago
Closed 20 months ago
#35325 closed Bug (duplicate)
CharField max_length ignored
| Reported by: | Aristotelis Mikropoulos | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 5.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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)
Note:
See TracTickets
for help on using tickets.
Duplicate of #21471.