Opened 7 years ago

Closed 7 years ago

Last modified 4 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)

Environment:

Request Method: POST
Request URL: http://www.xeroflow.com/admin/projects/project/add/
Django Version: 0.97-pre-SVN-7661
Python Version: 2.5.1
Installed Applications:
['django.contrib.sites',
 'django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.humanize',
 'django.contrib.flatpages',
 'django.contrib.admin',
 'django.contrib.sitemaps',
 'apps.attachments',
 'apps.tasks',
 'apps.comments',
 'apps.projects',
 'apps.assetpackager',
 'websites.xeroflow']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.cache.CacheMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.doc.XViewMiddleware')

Traceback:

File "/home/andurinc/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in add_stage
  264.             new_object = manipulator.save(new_data)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/manipulators.py" in save
  109.         new_object.save()
File "/home/andurinc/lib/python2.5/site-packages/django/db/abstract_models.py" in save
  33.         super(AbstractCategory, self).save(*args, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/base.py" in save
  270.         self.save_base()
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/base.py" in save_base
  332.                 result = manager._insert(values, return_id=update_pk)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/manager.py" in _insert
  118.         return insert_query(self.model, values, **kwargs)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/query.py" in insert_query
  735.     return query.execute_sql(return_id)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/sql/subqueries.py" in execute_sql
  300.         cursor = super(InsertQuery, self).execute_sql(None)
File "/home/andurinc/lib/python2.5/site-packages/django/db/models/sql/query.py" in execute_sql
  1474.         cursor.execute(sql, params)
File "/home/andurinc/lib/python2.5/site-packages/django/db/backends/util.py" 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 http://code.djangoproject.com/ticket/5996 have returned with the QSRF since when I went in and manually called unicode() on each param it worked fine.

Attachments (1)

base.py.patch (986 bytes) - added by Digitalxero@… 7 years ago.
Patch for the issue

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by Digitalxero@…

Patch for the issue

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

  • Description modified (diff)

comment:3 Changed 7 years ago by jacob

  • milestone set to 1.0
  • Triage Stage changed from Unreviewed to Accepted

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

comment:4 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:5 Changed 7 years ago by Llanilek

  • Needs documentation set

what base.py file does the patch need to be applied to?

comment:6 Changed 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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