Opened 6 years ago

Closed 6 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: master
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: UI/UX:

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)

comment:1 Changed 6 years ago by 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.

Ian

comment:2 in reply to:  1 Changed 6 years ago by Łukasz Rekucki

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.

Last edited 6 years ago by Łukasz Rekucki (previous) (diff)

comment:3 Changed 6 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

This is the same problem as #11027. (DB sounds like MySQL running in strict mode.)

Note: See TracTickets for help on using tickets.
Back to Top