Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7464 closed (fixed)

[QSRF] psycopg2 raises "can't adapt"

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: psycopg2, SafeUnicode, qsrf
Cc: digitalxero@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Ramiro Morales)


Request Method: POST
Request URL:
Django Version: 0.97-pre-SVN-7661
Python Version: 2.5.1
Installed Applications:
Installed Middleware:


File "/home/andurinc/lib/python2.5/site-packages/django/core/handlers/" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/contrib/admin/views/" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/views/decorators/" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/contrib/admin/views/" in add_stage
  264.             new_object =
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/" in save
File "/home/andurinc/lib/python2.5/site-packages/django/db/" in save
  33.         super(AbstractCategory, self).save(*args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/" in save
  270.         self.save_base()
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/" in save_base
  332.                 result = manager._insert(values, return_id=update_pk)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/" in _insert
  118.         return insert_query(self.model, values, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/" in insert_query
  735.     return query.execute_sql(return_id)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/sql/" in execute_sql
  300.         cursor = super(InsertQuery, self).execute_sql(None)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/sql/" in execute_sql
  1474.         cursor.execute(sql, params)
File "/home/andurinc/lib/python2.5/site-packages/django/db/backends/" in execute
  18.             return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/projects/project/add/
Exception Value: can't adapt
params = (u'Second Project', 'second-project', u'This is a second Project', u'2', u'2008-06-16 04:54:56.224657', True, u'Mercurial', u'http://changing.this.url/django/')
sql = 'INSERT INTO "projects_project" ("name", "slug", "description", "manager_id", "started", "public", "repository_type", "repository_url") VALUES (%s, %s, %s, %s, %s, %s, %s, %s)'

It seems the issues of have returned with the QSRF since when I went in and manually called unicode() on each param it worked fine.

Attachments (1) (986 bytes) - added by Digitalxero@… 8 years ago.
Patch for the issue

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by Digitalxero@…

Attachment: added

Patch for the issue

comment:1 Changed 8 years ago by Digitalxero@…

Has patch: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Attached a patch for this issue

comment:2 Changed 8 years ago by Ramiro Morales

Description: modified (diff)

comment:3 Changed 8 years ago by Jacob

milestone: 1.0
Triage Stage: UnreviewedAccepted

Looks like we need a similar change to [6816] to adapt SafeString as well.

comment:4 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [8532]) Fixed #7464 -- Fixed the psycopg2 backend to handle SafeString values as
parameters. Based on a patch from Digitalxero@….

comment:5 Changed 8 years ago by Llanilek

Needs documentation: set

what file does the patch need to be applied to?

comment:6 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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