Opened 14 years ago
Closed 14 years ago
#15278 closed (duplicate)
Validation error instead of exception when path length in FileField exceeds varchar(100) or max_length
Reported by: | ijstokes | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | FileField max_length "path length" | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I've just spent an hour digging into why Django throws a strange exception about "Data truncated for column 'upload_file' at row 1" somehow tied to a FileField and the SQL INSERT statement. Turns out it is just because the path length exceeds the default varchar(100). Doing a check of the path length and returning a validation error should be done instead of throwing a weird exception.
Change History (3)
follow-up: 2 comment:1 by , 14 years ago
comment:2 by , 14 years ago
Replying to ijstokes:
As an added note, I don't know if this is expected or not, but updating the FileField max_length after the fact and then doing syncdb doesn't change the schema. I had to manually do an "ALTER TABLE" to increase the size of the path field in the DB.
Yes this is expected - syncdb never alters any table once it already exists.
Btw, it would be useful to know what DB backend you are using.
comment:3 by , 14 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is the same problem as #11027. (DB sounds like MySQL running in strict mode.)
As an added note, I don't know if this is expected or not, but updating the FileField max_length after the fact and then doing syncdb doesn't change the schema. I had to manually do an "ALTER TABLE" to increase the size of the path field in the DB.
Ian