Relative support of old versions of SQLite that do not understand "PRAGMA read_uncommitted"
Mac OS X 10.4 ships with SQLite 3.1.3. Since SQLAlchemy 0.7, I am not able to use this version of SQLite anymore. Here is a test failure (I get the same error for all tests that involve SQLite):
$ ./sqla_nose.py test.dialect.test_sqlite:TestTypes.test_boolean
E
======================================================================
ERROR: test.dialect.test_sqlite.TestTypes.test_boolean
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/damien/env/lasco/lib/python2.7/site-packages/nose-1.0.0-py2.7.egg/nose/case.py", line 187, in runTest
self.test(*self.arg)
File "/Users/damien/dev/sqlalchemy/./test/dialect/test_sqlite.py", line 44, in test_boolean
meta.drop_all()
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/schema.py", line 2401, in drop_all
bind.drop(self, checkfirst=checkfirst, tables=tables)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/engine/base.py", line 1976, in drop
connection=connection, **kwargs)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/engine/base.py", line 2004, in _run_visitor
conn = self.contextual_connect(close_with_result=False)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/engine/base.py", line 2098, in contextual_connect
self.pool.connect(),
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/pool.py", line 218, in connect
agent = _ConnectionFairy(self)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/pool.py", line 370, in __init__
rec = self._connection_record = pool._do_get()
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/pool.py", line 557, in _do_get
c = self._create_connection()
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/pool.py", line 174, in _create_connection
return _ConnectionRecord(self)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/pool.py", line 258, in __init__
pool.dispatch.first_connect.exec_once(self.connection, self)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/event.py", line 265, in exec_once
self(*args, **kw)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/event.py", line 274, in __call__
fn(*args, **kw)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/engine/strategies.py", line 161, in first_connect
dialect.initialize(c)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/engine/default.py", line 181, in initialize
self.get_isolation_level(connection.connection)
File "/Users/damien/dev/sqlalchemy/./lib/sqlalchemy/dialects/sqlite/base.py", line 508, in get_isolation_level
value = cursor.fetchone()[0](0)
TypeError: 'NoneType' object is not subscriptable
----------------------------------------------------------------------
Ran 1 test in 0.010s
FAILED (errors=1)
This is because "PRAGMA read_uncommitted" is ignored by this old version of SQLite:
sqlite> PRAGMA read_uncommitted;
sqlite>
SQLite does not return any result at all, hence the error in the traceback. The work around is obvious (see attached patch against the tip).
I think that this pragma directive has been added in SQLite 3.3.0 according to the changelog. SQLite 3.3 has been released in January 2006 so I would understand if you rejected this bug as "Won't fix, you need to upgrade". On the other hand, this is the sole bug I have encountered so far on a small project since I switched to SQLAlchemy 0.7 (granted, I do not do anything fancy there).
Comments (3)
-
repo owner -
repo owner - changed status to resolved
thanks for the patch ! 8c09969d44c7d66634c3a392f17383ebfacb2881
-
repo owner - removed milestone
Removing milestone: 0.7.1 (automated comment)
- Log in to comment
its good to know its on a very dated version. There's no problem with the patch I'll just stick a comment in there as to its rationale.