﻿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
7636	Transaction logic with sqlite3 and seems to be broken.	lakin	nobody	"Here is an example from the python manage.py shell:
{{{
In [1]: from django.db import transaction

In [2]: from flemish_eye.models import FileCode

In [3]: for fc in FileCode.objects.all():
   ...:     fc.save()
   ...: 
---------------------------------------------------------------------------
<class 'sqlite3.OperationalError'>        Traceback (most recent call last)

/home/lakin/Projects/flemish_eye/trunk/flemish_eye/<ipython console> in <module>()

/home/lakin/Projects/django/trunk/django/db/models/base.py in save(self)
    275         control the saving process.
    276         """"""
--> 277         self.save_base()
    278 
    279     save.alters_data = True

/home/lakin/Projects/django/trunk/django/db/models/base.py in save_base(self, raw, cls)
    344             if update_pk:
    345                 setattr(self, meta.pk.attname, result)
--> 346         transaction.commit_unless_managed()
    347 
    348         if signal:

/home/lakin/Projects/django/trunk/django/db/transaction.py in commit_unless_managed()
    138     """"""
    139     if not is_managed():
--> 140         connection._commit()
    141     else:
    142         set_dirty()

/home/lakin/Projects/django/trunk/django/db/backends/__init__.py in _commit(self)
     18     def _commit(self):
     19         if self.connection is not None:
---> 20             return self.connection.commit()
     21 
     22     def _rollback(self):

<class 'sqlite3.OperationalError'>: SQL logic error or missing database

In [4]: @transaction.commit_manually
   ...: def doit():
   ...:     transaction.commit()
   ...:     try:
   ...:         for fc in FileCode.objects.all():
   ...:             fc.save()
   ...:     finally:
   ...:         transaction.commit()
   ...: 

In [5]: doit()

In [6]: 
}}}

Although if I put similar code in a view or in a def save on a model, I get the same effect. :/

"		closed	Uncategorized	dev		duplicate			Unreviewed	0	0	0	0	0	0
