#9893: Filename + path length greater than 100 truncated on database insertion
in
Core.Storage
-------------------------------------+--------------------------------------
Reporter: Refefer | Owner: nobody
Status: new | Milestone: 1.1
Component: Core framework | Version: SVN
Resolution: | Keywords: storage, filename
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------+--------------------------------------
Comment (by akaihola):
I ran into this issue when using the [http://code.google.com/p/django-
attachments/ django-attachments] re-usable app, but in my case the file
name wasn't truncated – an exception was thrown instead. I'm storing files
in subdirectories named after the user who uploads (max 30 characters),
and apparently one of my users was uploading a file with a really long
name so `len("attachments/<username>/<filename.ext>")` exceeded 100
characters.
I wonder why an exception happened instead of truncation. I'm using
PostgreSQL, maybe that's significant?
Here's the relevant part of the traceback:
{{{
File "attachments/attachments/models.py", line 137, in save
super(Attachment, self).save(force_insert, force_update)
File "django/db/models/base.py", line 408, in save
self.save_base(force_insert=force_insert, force_update=force_update)
File "django/db/models/base.py", line 484, in save_base
result = manager._insert(values, return_id=update_pk)
File "django/db/models/manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "django/db/models/query.py", line 1035, in insert_query
return query.execute_sql(return_id)
File "django/db/models/sql/subqueries.py", line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File "django/db/models/sql/query.py", line 2290, in execute_sql
cursor.execute(sql, params)
DataError: value too long for type character varying(100)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/9893#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---