#15818: PostgreSQL autocommit mode breaks initial insert
--------------------+---------------------------------------------
 Reporter:  Rick@…  |         Owner:  nobody
     Type:  Bug     |        Status:  new
Milestone:          |     Component:  Database layer (models, ORM)
  Version:  SVN     |      Severity:  Release blocker
 Keywords:          |  Triage Stage:  Unreviewed
Has patch:  0       |
--------------------+---------------------------------------------
 Settings used:
 {{{#!python
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         'NAME': 'django_test',           # Or path to database file if
 using sqlite3.
         'USER': '',                      # Not used with sqlite3.
         'PASSWORD': '',                  # Not used with sqlite3.
         'HOST': '',                      # Set to empty string for
 localhost. Not used with sqlite3.
         'PORT': '',                      # Set to empty string for
 default. Not used with sqlite3.
         'OPTIONS': {
             'autocommit': True,
         },
     }
 }
 }}}

 Code to reproduce:
 {{{#!python
 from django.conf import settings
 from django.contrib.auth.models import User
 user = User(username='something')
 user.save()
 }}}

 Stacktrace when executing:
 {{{#!python
 Traceback (most recent call last):
   File "test.py", line 5, in <module>
     user.save()
   File "django/db/models/base.py", line 461, in save
     self.save_base(using=using, force_insert=force_insert,
 force_update=force_update)
   File "django/db/models/base.py", line 554, in save_base
     result = manager._insert(values, return_id=update_pk, using=using)
   File "django/db/models/manager.py", line 195, in _insert
     return insert_query(self.model, values, **kwargs)
   File "django/db/models/query.py", line 1434, in insert_query
     return query.get_compiler(using=using).execute_sql(return_id)
   File "django/db/models/sql/compiler.py", line 795, in execute_sql
     return self.connection.ops.fetch_returned_insert_id(cursor)
   File "django/db/backends/__init__.py", line 460, in
 fetch_returned_insert_id
     return cursor.fetchone()[0]
 psycopg2.ProgrammingError: no results to fetch
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15818>
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.

Reply via email to