﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11076	@transaction.commit_on_success does not seem to work as documented	Pierre	nobody	"Observed on 1.0.2, but seems to be the same on 1.1.

Note that this is similar to ticket #9964, but not identical (the
issue presented here is much narrower).

I'm working on a simple view using the @transaction.commit_on_success
decorator.

The view does UPDATE requests to a legacy database (through a custom
Python module).

Sample code (simplified)
{{{
@transaction.commit_on_success
def myview(request):
  # ...
  if request.method == ""POST"":
    # no Django model calls;
    # some calls causing an UPDATE
  # ...
  return render_to_response(...)
}}}

The work is always rolled-back by Django at the end of the view.

From django.db.transaction it appears that the commit() is done
only if a call to set_dirty() has been made previously:

{{{
                if is_dirty():
                    commit()
}}}

Which in my case does not happen (unless I call it explicitly, of
course).
The documentation states:

{{{
If the function returns successfully, then Django will commit all work done
within the function at that point. If the function raises an exception, though, Django will
roll back the transaction.
}}}

As compared with the description of autocommit, which states things
explicitly, this seems to imply that the commit() is done in all
cases, dirty or not, so I found the actual behaviour surprising.

I don't know where is the best place to fix this, code or doc, but
in case you think it's the code... see attached patch :-)
"		closed	Database layer (models, ORM)	1.0		duplicate	@commit_on_success, set_dirty		Unreviewed	1	0	0	0	0	0
