Does anyone run the test suite with sqlite?
It sure doesn't look like it: 77 passed, 102 failed, trunk, revision 1827.

I also know what's happening now and can see that
sqlobject.tests.test_transactions is exposing the issue, and currently
failing.  the way pysqlite does transactions [1] is that it accepts
isolation_level = None for autocommit and isolation_level = "" (the
default) for transactions.  The problem is that sqlite is not threaded
so when you start a transaction, ALL connections will be inside a
transaction, even after you commit (i.e. they will be in a new
transaction).  Since transactions are connection wrappers in
sqlobject, a sort-of "threaded" situation should at least be
simulated.

In other words, the fix should be that sqlite goes back to
isolation_level=None after a transaction is committed.  I think.  I
don't know if that would break a lot of other stuff since all the
tests are already failing.  Also, looking at the code this is a little
hard to do since there is no commit() hook per driver connection
object.  Just wanted to throw this out there in case someone else was
googling for bugs in sqlobject + sqlite transactions.  I can work
around it now by doing my clearTable() inside a transaction, but that
is confusing.

-kumar

[1] 
http://initd.org/pub/software/pysqlite/doc/usage-guide.html#controlling-transactions

On 7/7/06, Kumar McMillan <[EMAIL PROTECTED]> wrote:
> I just confirmed that this behavior is *not* happening in postgres
> (via psycopg2).  transactions don't work with pysqlite1 so I can't
> deduce yet if this is a problem with psyqlite2 itself.  not sure if
> there are other sqlite drivers for python.
>
> On 7/6/06, Kumar McMillan <[EMAIL PROTECTED]> wrote:
> > this is driving me nuts!  After re-reading the docs and the code
> > itself I can't find any reason why this should be happening (below).
> > Specifically, the first commited insert comes back to life after the
> > second transaction is rolled back.  Does anyone have any suggestions
> > or insight?
> > SQLObject-0.8dev_r1814
> >
> > thanks in advance,
> > Kumar
> >
> > _
> >
> > from sqlobject import *
> >
> > class Person(SQLObject):
> >     class sqlmeta:
> >         cacheValues = False
> >     name = StringCol()
> >
> > conn = connectionForURI('sqlite:/:memory:')
> > print conn.getConnection()
> > conn.debug = 1
> > Person._connection = conn
> > Person.createTable()
> >
> > trans = conn.transaction()
> > new_p = Person(connection=trans, name='bob')
> > trans.commit()
> > print list(Person.select())
> >
> > Person.clearTable()
> > print list(Person.select())
> >
> > trans = conn.transaction()
> > new_p = Person(connection=trans, name='andy')
> > print list(Person.select())
> > trans.rollback()
> > print list(Person.select())
> >
> > >>> test_sqlite_trans.py
> >
> > <pysqlite2.dbapi2.Connection object at 0x562020>
> >  2/Query   :  CREATE TABLE person (
> >     id INTEGER PRIMARY KEY,
> >     name TEXT
> > )
> >  2/QueryR  :  CREATE TABLE person (
> >     id INTEGER PRIMARY KEY,
> >     name TEXT
> > )
> >  3/QueryIns:  INSERT INTO person (name) VALUES ('bob')
> >  3/QueryOne:  SELECT name FROM person WHERE id = (1)
> >  3/QueryR  :  SELECT name FROM person WHERE id = (1)
> >  3/COMMIT  :
> >  4/Select  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> >  4/QueryR  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> >  5/QueryOne:  SELECT name FROM person WHERE id = (1)
> >  5/QueryR  :  SELECT name FROM person WHERE id = (1)
> > [<Person 1 name='bob'>]
> >  6/Query   :  DELETE FROM person
> >  6/QueryR  :  DELETE FROM person
> >  7/Select  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> >  7/QueryR  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> > []
> >  8/QueryIns:  INSERT INTO person (name) VALUES ('andy')
> >  8/QueryOne:  SELECT name FROM person WHERE id = (1)
> >  8/QueryR  :  SELECT name FROM person WHERE id = (1)
> >  9/Select  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> >  9/QueryR  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> > 10/QueryOne:  SELECT name FROM person WHERE id = (1)
> > 10/QueryR  :  SELECT name FROM person WHERE id = (1)
> > [<Person 1 name='andy'>]
> > 10/ROLLBACK:
> > 11/Select  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> > 11/QueryR  :  SELECT person.id, person.name FROM person WHERE 1 = 1
> > 12/QueryOne:  SELECT name FROM person WHERE id = (1)
> > 12/QueryR  :  SELECT name FROM person WHERE id = (1)
> > [<Person 1 name='bob'>]
> >
>

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to