#10476: Fix(?) model insert handling when autcommit=True for PostgreSQL <= 8.1 ---------------------------------------------------+------------------------ Reporter: mtredinnick | Owner: mtredinnick Status: new | Milestone: 1.1 Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: Stage: Accepted | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by Richard Davies <richard.dav...@elastichosts.com>):
* has_patch: 0 => 1 * milestone: => 1.1 Comment: It turns out that the current code already works on PostgreSQL <= 8.1. I'm attaching a patch which simply removes the check (and some documentation of the limitation). This means that we'll be able to get database-native autocommit into 1.1. for all versions of PostgreSQL - good! The secret is that django/db/backends/postgresql/operations.py already defines last_insert_id() in terms of 'select currval' which is defined to be a session-local value (see http://www.postgresql.org/docs/7.3/static /functions-sequence.html or any other version). When django/db/models/sql/subqueries.py defines InsertQuery.execute_sql(), the version which uses return last_insert_id() is already session-safe, even in database-native autocommit mode without a wrapping transaction. The version which uses the 'returning' syntax on Postgresql >= 8.2 is simply more efficient, not more session-safe. -- Ticket URL: <http://code.djangoproject.com/ticket/10476#comment:5> 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 django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---