- marked as minor
Warn for usage of old pysqlite2 version
Issue #302
resolved
On my platform (WinXP/Python 2.4.0) pysqlite2 version 2.1.3 is the minimum required to pass the test suite (at rev 1869). 2.0.3 produces the exceptions below. Versions 2.1.0 through 2.1.2 produce far more exceptions. This could simply be documented, but a runtime warning seems appropriate.
The following patch issues a warning in the case of an old pysqlite2:
Index: sqlite.py
===================================================================
--- sqlite.py (revision 1869)
+++ sqlite.py (working copy)
@@ -24,6 +24,14 @@
sqlite = __import__('sqlite') # skip ourselves
except:
sqlite = None
+
+sqlite_ver = sqlite.version_info
+if sqlite_ver < (2,2) and sqlite_ver != (2,1,'3'):
+ import warnings
+ warnings.warn(RuntimeWarning(
+ "The installed version of pysqlite2 is out-dated, and will cause " +
+ "errors in some cases.\nPlease upgrade to version 2.1.3 or later"))
+ del warnings
class SLNumeric(sqltypes.Numeric):
def get_col_spec(self):
Errors with pysqlite2 version 2.0.3:
sqlalchemy SVN Rev 1869 (same results with Rev 1868, 1800) Windows XP SP2 Python 2.4.0 pysqlite2.dbapi2.version '2.0.3'
C:\PythonLibs\sqlalchemy>python test/alltests.py --quiet
................................................................................
.................F...........................................................F..
F.....................FF.....................F..................................
................................................................................
................................
======================================================================
FAIL: testcast (sql.select.SelectTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PythonLibs\sqlalchemy\test\sql\select.py", line 597, in testcast
check_results(sqlite.dialect(), [2)', 'NUMERIC(12, 9)', 'DATE',
'TEXT', 'VARCHAR(20)']('NUMERIC(10,), '?')
File "C:\PythonLibs\sqlalchemy\test\sql\select.py", line 583, in check_results
self.assertEqual(str(cast(tbl.c.v1, Numeric).compile(dialect=dialect)), 'CAS
T(casttest.v1 AS %s)' %expected_results[0](0))
AssertionError: 'casttest.v1' != 'CAST(casttest.v1 AS NUMERIC(10, 2))'
======================================================================
FAIL: testinsert (sql.defaults.DefaultTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PythonLibs\sqlalchemy\test\sql\defaults.py", line 96, in testinsert
self.assert_(l.fetchall() == ['imthedefault', f, ts, ts, ctexec), (52,
'imthedefault', f, ts, ts, ctexec), (53, 'imthedefault', f, ts, ts, ctexec)]((51,))
AssertionError
======================================================================
FAIL: testupdate (sql.defaults.DefaultTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PythonLibs\sqlalchemy\test\sql\defaults.py", line 112, in testupdate
self.assert_(l == (pk, 'im the update', f2, None, None, ctexec))
AssertionError
======================================================================
FAIL: testorderby (orm.mapper.EagerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PythonLibs\sqlalchemy\test\orm\mapper.py", line 821, in testorderby
{'user_id' : 9, 'addresses' : (Address, [ File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 180, in assert_result
self.assert_list(result, class_, objects)
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 184, in assert_list
self.assert_row(class_, result[i](])}
), list[i](i))
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 190, in assert_row
self.assert_list(getattr(rowobj, key), value[0](0), value[1](1))
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 184, in assert_list
self.assert_row(class_, result[i](i), list[i](i))
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 194, in assert_row
self.assert_(getattr(rowobj, key) == value, "attribute %s value %s does not
match %s" % (key, getattr(rowobj, key), value))
AssertionError: attribute email_address value ed@wood.com does not match ed@bett
yboop.com
======================================================================
FAIL: testorderby_desc (orm.mapper.EagerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PythonLibs\sqlalchemy\test\orm\mapper.py", line 836, in testorderby_d
esc
{'user_id' : 9, 'addresses' : (Address, [ File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 180, in assert_result
self.assert_list(result, class_, objects)
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 184, in assert_list
self.assert_row(class_, result[i](])},
), list[i](i))
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 190, in assert_row
self.assert_list(getattr(rowobj, key), value[0](0), value[1](1))
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 184, in assert_list
self.assert_row(class_, result[i](i), list[i](i))
File "C:\PythonLibs\sqlalchemy\test\testbase.py", line 194, in assert_row
self.assert_(getattr(rowobj, key) == value, "attribute %s value %s does not
match %s" % (key, getattr(rowobj, key), value))
AssertionError: attribute email_address value ed@bettyboop.com does not match ed
@lala.com
======================================================================
FAIL: testfunction (orm.mapper.MapperTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\PythonLibs\sqlalchemy\test\orm\mapper.py", line 342, in testfunction
assert l[0](0).concat == l[0](0).user_id * 2 == 14
AssertionError
----------------------------------------------------------------------
Ran 352 tests in 16.854s
Comments (3)
-
repo owner -
repo owner - marked as major
i think I also want to set the sqlalchemy default log level to WARN.
-
repo owner - changed status to resolved
OK using warnings module now, changeset:2528
- Log in to comment