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)

comment:1 by ijstokes, 14 years ago

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

in reply to:  1 comment:2 by Łukasz Rekucki, 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 are you using.

Version 0, edited 14 years ago by Łukasz Rekucki (next)

comment:3 by Karen Tracey, 14 years ago

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