sqlobject-cvs Mailing List for SQLObject (Page 25)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sub...@co...> - 2013-08-29 20:12:07
|
Author: phd Date: Thu Aug 29 14:12:01 2013 New Revision: 4659 Log: Release 1.5.0rc1 Modified: SQLObject/tags/1.5.0rc1/README.txt SQLObject/tags/1.5.0rc1/setup.py SQLObject/tags/1.5.0rc1/sqlobject/__version__.py Modified: SQLObject/tags/1.5.0rc1/README.txt ============================================================================== --- SQLObject/tags/1.5.0rc1/README.txt Thu Aug 29 14:07:06 2013 (r4658) +++ SQLObject/tags/1.5.0rc1/README.txt Thu Aug 29 14:12:01 2013 (r4659) @@ -1,5 +1,5 @@ -SQLObject 1.5 -============= +SQLObject 1.5.0rc1 +================== Thanks for looking at SQLObject. SQLObject is an object-relational mapper, i.e., a library that will wrap your database tables in Python Modified: SQLObject/tags/1.5.0rc1/setup.py ============================================================================== --- SQLObject/tags/1.5.0rc1/setup.py Thu Aug 29 14:07:06 2013 (r4658) +++ SQLObject/tags/1.5.0rc1/setup.py Thu Aug 29 14:12:01 2013 (r4659) @@ -56,7 +56,7 @@ author="Ian Bicking", author_email="ia...@co...", url="http://sqlobject.org/", - download_url="https://pypi.python.org/pypi/SQLObject/%s" % version, + download_url="https://pypi.python.org/pypi/SQLObject/1.5.0rc1dev-r4659", license="LGPL", packages=["sqlobject"] + ['sqlobject.%s' % package for package in subpackages], scripts=["scripts/sqlobject-admin", "scripts/sqlobject-convertOldURI"], Modified: SQLObject/tags/1.5.0rc1/sqlobject/__version__.py ============================================================================== --- SQLObject/tags/1.5.0rc1/sqlobject/__version__.py Thu Aug 29 14:07:06 2013 (r4658) +++ SQLObject/tags/1.5.0rc1/sqlobject/__version__.py Thu Aug 29 14:12:01 2013 (r4659) @@ -1,8 +1,8 @@ -version = '1.5' +version = '1.5.0rc1' major = 1 minor = 5 micro = 0 -release_level = 'branch' -serial = 0 +release_level = 'release candidate' +serial = 1 version_info = (major, minor, micro, release_level, serial) |
From: <sub...@co...> - 2013-08-29 20:07:17
|
Author: phd Date: Thu Aug 29 14:07:06 2013 New Revision: 4658 Log: Tagging 1.5.0rc1 Added: SQLObject/tags/1.5.0rc1/ - copied from r4657, SQLObject/branches/1.5/ |
From: <sub...@co...> - 2013-08-26 19:18:07
|
Author: phd Date: Mon Aug 26 13:18:01 2013 New Revision: 4657 Log: Merged revisions 4654:4656 from branch 1.5 Minor refactoring: slightly reorder some parts of code. Remove setDeprecationLevel from the list of public functions. Support for Python 2.4 is declared obsolete. Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/main.py Modified: SQLObject/trunk/docs/News.txt ============================================================================== --- SQLObject/trunk/docs/News.txt Mon Aug 26 13:16:22 2013 (r4656) +++ SQLObject/trunk/docs/News.txt Mon Aug 26 13:18:01 2013 (r4657) @@ -19,11 +19,16 @@ * Helpers for class Outer were changed to lookup columns in table's declarations. +* Support for Python 2.4 is declared obsolete and will be removed + in the next release. + Minor features -------------- * Encode unicode enum values to str. +* Removed setDeprecationLevel from the list of public functions. + * A number of fixes for tests. Bugfixes Modified: SQLObject/trunk/sqlobject/main.py ============================================================================== --- SQLObject/trunk/sqlobject/main.py Mon Aug 26 13:16:22 2013 (r4656) +++ SQLObject/trunk/sqlobject/main.py Mon Aug 26 13:18:01 2013 (r4657) @@ -51,7 +51,6 @@ code-blocks to execute _after_ the whole hierachy of inherited SQLObjects is created. See SQLObject._create """ -_postponed_local = local() NoDefault = sqlbuilder.NoDefault @@ -632,22 +631,8 @@ sqlhub = dbconnection.ConnectionHub() -class _sqlmeta_attr(object): - - def __init__(self, name, deprecation_level): - self.name = name - self.deprecation_level = deprecation_level - def __get__(self, obj, type=None): - if self.deprecation_level is not None: - deprecated( - 'Use of this attribute should be replaced with ' - '.sqlmeta.%s' % self.name, level=self.deprecation_level) - return getattr((type or obj).sqlmeta, self.name) - - -# @@: This should become a public interface or documented or -# something. Turning it on gives earlier warning about things +# Turning it on gives earlier warning about things # that will be deprecated (having this off we won't flood people # with warnings right away). warnings_level = 1 @@ -663,8 +648,8 @@ if warnings_level is not None and warnings_level <= level: warnings.warn(message, DeprecationWarning, stacklevel=stacklevel) -#if sys.version_info[:3] < (2, 5, 0): -# deprecated("Support for Python 2.4 has been declared obsolete and will be removed in the next release of SQLObject") +if sys.version_info[:3] < (2, 5, 0): + deprecated("Support for Python 2.4 has been declared obsolete and will be removed in the next release of SQLObject") def setDeprecationLevel(warning=1, exception=None): """ @@ -677,12 +662,11 @@ The levels currently mean: - 1) Deprecated in current version (0.9). Will be removed in next - version (0.10) + 1) Deprecated in current version. Will be removed in next version. 2) Planned to deprecate in next version, remove later. - 3) Planned to deprecate sometime, remove sometime much later ;) + 3) Planned to deprecate sometime, remove sometime much later. As the SQLObject versions progress, the deprecation level of specific features will go down, indicating the advancing nature of @@ -698,6 +682,22 @@ exception_level = exception +class _sqlmeta_attr(object): + + def __init__(self, name, deprecation_level): + self.name = name + self.deprecation_level = deprecation_level + + def __get__(self, obj, type=None): + if self.deprecation_level is not None: + deprecated( + 'Use of this attribute should be replaced with ' + '.sqlmeta.%s' % self.name, level=self.deprecation_level) + return getattr((type or obj).sqlmeta, self.name) + + +_postponed_local = local() + # SQLObject is the superclass for all SQLObject classes, of # course. All the deeper magic is done in MetaSQLObject, and # only lesser magic is done here. All the actual work is done @@ -1742,7 +1742,7 @@ else: return obj -__all__ = ['NoDefault', 'SQLObject', 'sqlmeta', 'sqlhub', - 'getID', 'getObject', 'setDeprecationLevel', - 'SQLObjectNotFound', 'SQLObjectIntegrityError', +__all__ = ['NoDefault', 'SQLObject', + 'SQLObjectIntegrityError', 'SQLObjectNotFound', + 'getID', 'getObject', 'sqlhub', 'sqlmeta', ] |
From: <sub...@co...> - 2013-08-26 19:16:29
|
Author: phd Date: Mon Aug 26 13:16:22 2013 New Revision: 4656 Log: Support for Python 2.4 is declared obsolete Modified: SQLObject/branches/1.5/docs/News.txt SQLObject/branches/1.5/sqlobject/main.py Modified: SQLObject/branches/1.5/docs/News.txt ============================================================================== --- SQLObject/branches/1.5/docs/News.txt Mon Aug 26 13:13:28 2013 (r4655) +++ SQLObject/branches/1.5/docs/News.txt Mon Aug 26 13:16:22 2013 (r4656) @@ -16,6 +16,9 @@ * Helpers for class Outer were changed to lookup columns in table's declarations. +* Support for Python 2.4 is declared obsolete and will be removed + in the next release. + Minor features -------------- Modified: SQLObject/branches/1.5/sqlobject/main.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/main.py Mon Aug 26 13:13:28 2013 (r4655) +++ SQLObject/branches/1.5/sqlobject/main.py Mon Aug 26 13:16:22 2013 (r4656) @@ -648,8 +648,8 @@ if warnings_level is not None and warnings_level <= level: warnings.warn(message, DeprecationWarning, stacklevel=stacklevel) -#if sys.version_info[:3] < (2, 5, 0): -# deprecated("Support for Python 2.4 has been declared obsolete and will be removed in the next release of SQLObject") +if sys.version_info[:3] < (2, 5, 0): + deprecated("Support for Python 2.4 has been declared obsolete and will be removed in the next release of SQLObject") def setDeprecationLevel(warning=1, exception=None): """ |
From: <sub...@co...> - 2013-08-26 19:13:35
|
Author: phd Date: Mon Aug 26 13:13:28 2013 New Revision: 4655 Log: Remove setDeprecationLevel from the list of public functions Modified: SQLObject/branches/1.5/docs/News.txt SQLObject/branches/1.5/sqlobject/main.py Modified: SQLObject/branches/1.5/docs/News.txt ============================================================================== --- SQLObject/branches/1.5/docs/News.txt Mon Aug 26 13:11:05 2013 (r4654) +++ SQLObject/branches/1.5/docs/News.txt Mon Aug 26 13:13:28 2013 (r4655) @@ -21,6 +21,8 @@ * Encode unicode enum values to str. +* Removed setDeprecationLevel from the list of public functions. + * A number of fixes for tests. Bugfixes Modified: SQLObject/branches/1.5/sqlobject/main.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/main.py Mon Aug 26 13:11:05 2013 (r4654) +++ SQLObject/branches/1.5/sqlobject/main.py Mon Aug 26 13:13:28 2013 (r4655) @@ -1744,5 +1744,5 @@ __all__ = ['NoDefault', 'SQLObject', 'SQLObjectIntegrityError', 'SQLObjectNotFound', - 'getID', 'getObject', 'setDeprecationLevel', 'sqlhub', 'sqlmeta', + 'getID', 'getObject', 'sqlhub', 'sqlmeta', ] |
From: <sub...@co...> - 2013-08-26 19:11:13
|
Author: phd Date: Mon Aug 26 13:11:05 2013 New Revision: 4654 Log: Minor refactoring: slightly reorder some parts of code Modified: SQLObject/branches/1.5/sqlobject/main.py Modified: SQLObject/branches/1.5/sqlobject/main.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/main.py Tue Aug 20 07:30:31 2013 (r4653) +++ SQLObject/branches/1.5/sqlobject/main.py Mon Aug 26 13:11:05 2013 (r4654) @@ -51,7 +51,6 @@ code-blocks to execute _after_ the whole hierachy of inherited SQLObjects is created. See SQLObject._create """ -_postponed_local = local() NoDefault = sqlbuilder.NoDefault @@ -632,22 +631,8 @@ sqlhub = dbconnection.ConnectionHub() -class _sqlmeta_attr(object): - - def __init__(self, name, deprecation_level): - self.name = name - self.deprecation_level = deprecation_level - def __get__(self, obj, type=None): - if self.deprecation_level is not None: - deprecated( - 'Use of this attribute should be replaced with ' - '.sqlmeta.%s' % self.name, level=self.deprecation_level) - return getattr((type or obj).sqlmeta, self.name) - - -# @@: This should become a public interface or documented or -# something. Turning it on gives earlier warning about things +# Turning it on gives earlier warning about things # that will be deprecated (having this off we won't flood people # with warnings right away). warnings_level = 1 @@ -677,12 +662,11 @@ The levels currently mean: - 1) Deprecated in current version (0.9). Will be removed in next - version (0.10) + 1) Deprecated in current version. Will be removed in next version. 2) Planned to deprecate in next version, remove later. - 3) Planned to deprecate sometime, remove sometime much later ;) + 3) Planned to deprecate sometime, remove sometime much later. As the SQLObject versions progress, the deprecation level of specific features will go down, indicating the advancing nature of @@ -698,6 +682,22 @@ exception_level = exception +class _sqlmeta_attr(object): + + def __init__(self, name, deprecation_level): + self.name = name + self.deprecation_level = deprecation_level + + def __get__(self, obj, type=None): + if self.deprecation_level is not None: + deprecated( + 'Use of this attribute should be replaced with ' + '.sqlmeta.%s' % self.name, level=self.deprecation_level) + return getattr((type or obj).sqlmeta, self.name) + + +_postponed_local = local() + # SQLObject is the superclass for all SQLObject classes, of # course. All the deeper magic is done in MetaSQLObject, and # only lesser magic is done here. All the actual work is done @@ -1742,7 +1742,7 @@ else: return obj -__all__ = ['NoDefault', 'SQLObject', 'sqlmeta', 'sqlhub', - 'getID', 'getObject', 'setDeprecationLevel', - 'SQLObjectNotFound', 'SQLObjectIntegrityError', +__all__ = ['NoDefault', 'SQLObject', + 'SQLObjectIntegrityError', 'SQLObjectNotFound', + 'getID', 'getObject', 'setDeprecationLevel', 'sqlhub', 'sqlmeta', ] |
From: <sub...@co...> - 2013-08-20 13:30:38
|
Author: phd Date: Tue Aug 20 07:30:31 2013 New Revision: 4653 Log: Merged revisions 4649:4652 from branch 1.5 Import validators from sqlobject.col, not from formencode. Add dbEncoding parameter to SOCol. Move getDbEncoding to SOCol. Encode unicode enum values to str. Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/col.py SQLObject/trunk/sqlobject/tests/test_enum.py SQLObject/trunk/sqlobject/tests/test_validation.py Modified: SQLObject/trunk/docs/News.txt ============================================================================== --- SQLObject/trunk/docs/News.txt Tue Aug 20 07:28:06 2013 (r4652) +++ SQLObject/trunk/docs/News.txt Tue Aug 20 07:30:31 2013 (r4653) @@ -22,6 +22,8 @@ Minor features -------------- +* Encode unicode enum values to str. + * A number of fixes for tests. Bugfixes Modified: SQLObject/trunk/sqlobject/col.py ============================================================================== --- SQLObject/trunk/sqlobject/col.py Tue Aug 20 07:28:06 2013 (r4652) +++ SQLObject/trunk/sqlobject/col.py Tue Aug 20 07:30:31 2013 (r4653) @@ -25,10 +25,11 @@ import cPickle as pickle except ImportError: import pickle -# Sadly the name "constraints" conflicts with many of the function -# arguments in this module, so we rename it: +import weakref from formencode import compound, validators from classregistry import findClass +# Sadly the name "constraints" conflicts with many of the function +# arguments in this module, so we rename it: import constraints as constrs import sqlbuilder from styles import capword @@ -106,6 +107,7 @@ title=None, tags=[], origName=None, + dbEncoding=None, extra_vars=None): super(SOCol, self).__init__() @@ -197,6 +199,9 @@ if validator: _validators.append(validator) if validator2: _validators.insert(0, validator2) _vlen = len(_validators) + if _vlen: + for _validator in _validators: + _validator.soCol=weakref.proxy(self) if _vlen == 0: self.validator = None # Set sef.{from,to}_python elif _vlen == 1: @@ -210,6 +215,7 @@ self.origName = origName or name self.title = title self.tags = tags + self.dbEncoding = dbEncoding if extra_vars: for name, value in extra_vars.items(): @@ -368,6 +374,22 @@ def __delete__(self, obj): raise AttributeError("I can't be deleted from %r" % obj) + def getDbEncoding(self, state, default='utf-8'): + if self.dbEncoding: + return self.dbEncoding + dbEncoding = state.soObject.sqlmeta.dbEncoding + if dbEncoding: + return dbEncoding + try: + connection = state.connection or state.soObject._connection + except AttributeError: + dbEncoding = None + else: + dbEncoding = getattr(connection, "dbEncoding", None) + if not dbEncoding: + dbEncoding = default + return dbEncoding + class Col(object): @@ -410,6 +432,13 @@ self._name or '(unnamed)') +class SOValidator(validators.Validator): + def getDbEncoding(self, state, default='utf-8'): + try: + return self.dbEncoding + except AttributeError: + return self.soCol.getDbEncoding(state, default=default) + class SOStringLikeCol(SOCol): """A common ancestor for SOStringCol and SOUnicodeCol""" @@ -498,7 +527,7 @@ return self._sqlType() -class StringValidator(validators.Validator): +class StringValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -507,10 +536,8 @@ connection = state.connection or state.soObject._connection binaryType = connection._binaryType except AttributeError: - dbEncoding = "ascii" binaryType = type(None) # Just a simple workaround - else: - dbEncoding = getattr(connection, "dbEncoding", None) or "ascii" + dbEncoding = self.getDbEncoding(state, default='ascii') if isinstance(value, unicode): return value.encode(dbEncoding) if self.dataType and isinstance(value, self.dataType): @@ -544,13 +571,7 @@ assert db == 'mssql' return "N" + sqlbuilder.sqlrepr(self.value, db) -class UnicodeStringValidator(validators.Validator): - - def getDbEncoding(self, state): - try: - return self.dbEncoding - except AttributeError: - return self.soCol.getDbEncoding(state) +class UnicodeStringValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -586,40 +607,20 @@ (self.name, type(value), value), value, state) class SOUnicodeCol(SOStringLikeCol): - def __init__(self, **kw): - self.dbEncoding = kw.pop('dbEncoding', None) - super(SOUnicodeCol, self).__init__(**kw) - def _mssqlType(self): if self.customSQLType is not None: return self.customSQLType return 'N' + super(SOUnicodeCol, self)._mssqlType() def createValidators(self): - return [UnicodeStringValidator(name=self.name, soCol=self)] + \ + return [UnicodeStringValidator(name=self.name)] + \ super(SOUnicodeCol, self).createValidators() - def getDbEncoding(self, state): - if self.dbEncoding: - return self.dbEncoding - dbEncoding = state.soObject.sqlmeta.dbEncoding - if dbEncoding: - return dbEncoding - try: - connection = state.connection or state.soObject._connection - except AttributeError: - dbEncoding = None - else: - dbEncoding = getattr(connection, "dbEncoding", None) - if not dbEncoding: - dbEncoding = "utf-8" - return dbEncoding - class UnicodeCol(Col): baseClass = SOUnicodeCol -class IntValidator(validators.Validator): +class IntValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -700,7 +701,7 @@ baseClass = SOBigIntCol -class BoolValidator(validators.Validator): +class BoolValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -747,7 +748,7 @@ baseClass = SOBoolCol -class FloatValidator(validators.Validator): +class FloatValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -959,10 +960,13 @@ super(ForeignKey, self).__init__(foreignKey=foreignKey, **kw) -class EnumValidator(validators.Validator): +class EnumValidator(SOValidator): def to_python(self, value, state): if value in self.enumValues: + if isinstance(value, unicode): + dbEncoding = self.getDbEncoding(state) + value = value.encode(dbEncoding) return value elif not self.notNone and value is None: return None @@ -1032,7 +1036,7 @@ baseClass = SOEnumCol -class SetValidator(validators.Validator): +class SetValidator(SOValidator): """ Translates Python tuples into SQL comma-delimited SET strings. """ @@ -1330,7 +1334,7 @@ baseClass = SOTimestampCol -class TimedeltaValidator(validators.Validator): +class TimedeltaValidator(SOValidator): def to_python(self, value, state): return value @@ -1350,7 +1354,7 @@ from decimal import Decimal -class DecimalValidator(validators.Validator): +class DecimalValidator(SOValidator): def to_python(self, value, state): if value is None: return None @@ -1475,7 +1479,7 @@ baseClass = SODecimalStringCol -class BinaryValidator(validators.Validator): +class BinaryValidator(SOValidator): """ Validator for binary types. @@ -1566,12 +1570,7 @@ if value is None: return None if isinstance(value, unicode): - try: - connection = state.connection or state.soObject._connection - except AttributeError: - dbEncoding = "ascii" - else: - dbEncoding = getattr(connection, "dbEncoding", None) or "ascii" + dbEncoding = self.getDbEncoding(state, default='ascii') value = value.encode(dbEncoding) if isinstance(value, str): return pickle.loads(value) Modified: SQLObject/trunk/sqlobject/tests/test_enum.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_enum.py Tue Aug 20 07:28:06 2013 (r4652) +++ SQLObject/trunk/sqlobject/tests/test_enum.py Tue Aug 20 07:30:31 2013 (r4653) @@ -1,6 +1,6 @@ from sqlobject import * +from sqlobject.col import validators from sqlobject.tests.dbtest import * -from formencode import Invalid ######################################## ## Enum test @@ -17,9 +17,10 @@ raises( (Enum1._connection.module.IntegrityError, Enum1._connection.module.ProgrammingError, - Invalid), + validators.Invalid), Enum1, l='b') + class EnumWithNone(SQLObject): l = EnumCol(enumValues=['a', 'bcd', 'e', None]) @@ -30,6 +31,7 @@ e = EnumWithNone(l=l) assert e.l == l + class EnumWithDefaultNone(SQLObject): l = EnumCol(enumValues=['a', 'bcd', 'e', None], default=None) @@ -40,6 +42,7 @@ e = EnumWithDefaultNone() assert e.l == None + class EnumWithDefaultOther(SQLObject): l = EnumCol(enumValues=['a', 'bcd', 'e', None], default='a') @@ -49,3 +52,17 @@ e = EnumWithDefaultOther() assert e.l == 'a' + + +class EnumUnicode(SQLObject): + + n = UnicodeCol() + l = EnumCol(enumValues=['a', 'b']) + +def testUnicode(): + setupClass(EnumUnicode) + + EnumUnicode(n=u'a', l='a') + EnumUnicode(n=u'b', l=u'b') + EnumUnicode(n=u'\u201c', l='a') + EnumUnicode(n=u'\u201c', l=u'b') Modified: SQLObject/trunk/sqlobject/tests/test_validation.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_validation.py Tue Aug 20 07:28:06 2013 (r4652) +++ SQLObject/trunk/sqlobject/tests/test_validation.py Tue Aug 20 07:30:31 2013 (r4653) @@ -1,6 +1,6 @@ from sqlobject import * +from sqlobject.col import validators from sqlobject.tests.dbtest import * -from formencode import validators ######################################## ## Validation/conversion |
From: <sub...@co...> - 2013-08-20 13:28:12
|
Author: phd Date: Tue Aug 20 07:28:06 2013 New Revision: 4652 Log: Update News Modified: SQLObject/branches/1.5/docs/News.txt Modified: SQLObject/branches/1.5/docs/News.txt ============================================================================== --- SQLObject/branches/1.5/docs/News.txt Tue Aug 20 07:25:18 2013 (r4651) +++ SQLObject/branches/1.5/docs/News.txt Tue Aug 20 07:28:06 2013 (r4652) @@ -19,6 +19,8 @@ Minor features -------------- +* Encode unicode enum values to str. + * A number of fixes for tests. Bugfixes |
From: <sub...@co...> - 2013-08-20 13:25:28
|
Author: phd Date: Tue Aug 20 07:25:18 2013 New Revision: 4651 Log: Encode unicode enum values to str Modified: SQLObject/branches/1.5/sqlobject/col.py SQLObject/branches/1.5/sqlobject/tests/test_enum.py Modified: SQLObject/branches/1.5/sqlobject/col.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/col.py Tue Aug 20 07:21:21 2013 (r4650) +++ SQLObject/branches/1.5/sqlobject/col.py Tue Aug 20 07:25:18 2013 (r4651) @@ -964,6 +964,9 @@ def to_python(self, value, state): if value in self.enumValues: + if isinstance(value, unicode): + dbEncoding = self.getDbEncoding(state) + value = value.encode(dbEncoding) return value elif not self.notNone and value is None: return None Modified: SQLObject/branches/1.5/sqlobject/tests/test_enum.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_enum.py Tue Aug 20 07:21:21 2013 (r4650) +++ SQLObject/branches/1.5/sqlobject/tests/test_enum.py Tue Aug 20 07:25:18 2013 (r4651) @@ -52,3 +52,17 @@ e = EnumWithDefaultOther() assert e.l == 'a' + + +class EnumUnicode(SQLObject): + + n = UnicodeCol() + l = EnumCol(enumValues=['a', 'b']) + +def testUnicode(): + setupClass(EnumUnicode) + + EnumUnicode(n=u'a', l='a') + EnumUnicode(n=u'b', l=u'b') + EnumUnicode(n=u'\u201c', l='a') + EnumUnicode(n=u'\u201c', l=u'b') |
From: <sub...@co...> - 2013-08-20 13:21:30
|
Author: phd Date: Tue Aug 20 07:21:21 2013 New Revision: 4650 Log: Add dbEncoding parameter to SOCol. Move getDbEncoding to SOCol. Modified: SQLObject/branches/1.5/sqlobject/col.py Modified: SQLObject/branches/1.5/sqlobject/col.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/col.py Tue Aug 20 07:18:31 2013 (r4649) +++ SQLObject/branches/1.5/sqlobject/col.py Tue Aug 20 07:21:21 2013 (r4650) @@ -25,10 +25,11 @@ import cPickle as pickle except ImportError: import pickle -# Sadly the name "constraints" conflicts with many of the function -# arguments in this module, so we rename it: +import weakref from formencode import compound, validators from classregistry import findClass +# Sadly the name "constraints" conflicts with many of the function +# arguments in this module, so we rename it: import constraints as constrs import sqlbuilder from styles import capword @@ -106,6 +107,7 @@ title=None, tags=[], origName=None, + dbEncoding=None, extra_vars=None): super(SOCol, self).__init__() @@ -197,6 +199,9 @@ if validator: _validators.append(validator) if validator2: _validators.insert(0, validator2) _vlen = len(_validators) + if _vlen: + for _validator in _validators: + _validator.soCol=weakref.proxy(self) if _vlen == 0: self.validator = None # Set sef.{from,to}_python elif _vlen == 1: @@ -210,6 +215,7 @@ self.origName = origName or name self.title = title self.tags = tags + self.dbEncoding = dbEncoding if extra_vars: for name, value in extra_vars.items(): @@ -368,6 +374,22 @@ def __delete__(self, obj): raise AttributeError("I can't be deleted from %r" % obj) + def getDbEncoding(self, state, default='utf-8'): + if self.dbEncoding: + return self.dbEncoding + dbEncoding = state.soObject.sqlmeta.dbEncoding + if dbEncoding: + return dbEncoding + try: + connection = state.connection or state.soObject._connection + except AttributeError: + dbEncoding = None + else: + dbEncoding = getattr(connection, "dbEncoding", None) + if not dbEncoding: + dbEncoding = default + return dbEncoding + class Col(object): @@ -410,6 +432,13 @@ self._name or '(unnamed)') +class SOValidator(validators.Validator): + def getDbEncoding(self, state, default='utf-8'): + try: + return self.dbEncoding + except AttributeError: + return self.soCol.getDbEncoding(state, default=default) + class SOStringLikeCol(SOCol): """A common ancestor for SOStringCol and SOUnicodeCol""" @@ -498,7 +527,7 @@ return self._sqlType() -class StringValidator(validators.Validator): +class StringValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -507,10 +536,8 @@ connection = state.connection or state.soObject._connection binaryType = connection._binaryType except AttributeError: - dbEncoding = "ascii" binaryType = type(None) # Just a simple workaround - else: - dbEncoding = getattr(connection, "dbEncoding", None) or "ascii" + dbEncoding = self.getDbEncoding(state, default='ascii') if isinstance(value, unicode): return value.encode(dbEncoding) if self.dataType and isinstance(value, self.dataType): @@ -544,13 +571,7 @@ assert db == 'mssql' return "N" + sqlbuilder.sqlrepr(self.value, db) -class UnicodeStringValidator(validators.Validator): - - def getDbEncoding(self, state): - try: - return self.dbEncoding - except AttributeError: - return self.soCol.getDbEncoding(state) +class UnicodeStringValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -586,40 +607,20 @@ (self.name, type(value), value), value, state) class SOUnicodeCol(SOStringLikeCol): - def __init__(self, **kw): - self.dbEncoding = kw.pop('dbEncoding', None) - super(SOUnicodeCol, self).__init__(**kw) - def _mssqlType(self): if self.customSQLType is not None: return self.customSQLType return 'N' + super(SOUnicodeCol, self)._mssqlType() def createValidators(self): - return [UnicodeStringValidator(name=self.name, soCol=self)] + \ + return [UnicodeStringValidator(name=self.name)] + \ super(SOUnicodeCol, self).createValidators() - def getDbEncoding(self, state): - if self.dbEncoding: - return self.dbEncoding - dbEncoding = state.soObject.sqlmeta.dbEncoding - if dbEncoding: - return dbEncoding - try: - connection = state.connection or state.soObject._connection - except AttributeError: - dbEncoding = None - else: - dbEncoding = getattr(connection, "dbEncoding", None) - if not dbEncoding: - dbEncoding = "utf-8" - return dbEncoding - class UnicodeCol(Col): baseClass = SOUnicodeCol -class IntValidator(validators.Validator): +class IntValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -700,7 +701,7 @@ baseClass = SOBigIntCol -class BoolValidator(validators.Validator): +class BoolValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -747,7 +748,7 @@ baseClass = SOBoolCol -class FloatValidator(validators.Validator): +class FloatValidator(SOValidator): def to_python(self, value, state): if value is None: @@ -959,7 +960,7 @@ super(ForeignKey, self).__init__(foreignKey=foreignKey, **kw) -class EnumValidator(validators.Validator): +class EnumValidator(SOValidator): def to_python(self, value, state): if value in self.enumValues: @@ -1032,7 +1033,7 @@ baseClass = SOEnumCol -class SetValidator(validators.Validator): +class SetValidator(SOValidator): """ Translates Python tuples into SQL comma-delimited SET strings. """ @@ -1330,7 +1331,7 @@ baseClass = SOTimestampCol -class TimedeltaValidator(validators.Validator): +class TimedeltaValidator(SOValidator): def to_python(self, value, state): return value @@ -1350,7 +1351,7 @@ from decimal import Decimal -class DecimalValidator(validators.Validator): +class DecimalValidator(SOValidator): def to_python(self, value, state): if value is None: return None @@ -1475,7 +1476,7 @@ baseClass = SODecimalStringCol -class BinaryValidator(validators.Validator): +class BinaryValidator(SOValidator): """ Validator for binary types. @@ -1566,12 +1567,7 @@ if value is None: return None if isinstance(value, unicode): - try: - connection = state.connection or state.soObject._connection - except AttributeError: - dbEncoding = "ascii" - else: - dbEncoding = getattr(connection, "dbEncoding", None) or "ascii" + dbEncoding = self.getDbEncoding(state, default='ascii') value = value.encode(dbEncoding) if isinstance(value, str): return pickle.loads(value) |
From: <sub...@co...> - 2013-08-20 13:18:39
|
Author: phd Date: Tue Aug 20 07:18:31 2013 New Revision: 4649 Log: Import validators from sqlobject.col, not from formencode Modified: SQLObject/branches/1.5/sqlobject/tests/test_enum.py SQLObject/branches/1.5/sqlobject/tests/test_validation.py Modified: SQLObject/branches/1.5/sqlobject/tests/test_enum.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_enum.py Mon Aug 19 06:23:20 2013 (r4648) +++ SQLObject/branches/1.5/sqlobject/tests/test_enum.py Tue Aug 20 07:18:31 2013 (r4649) @@ -1,6 +1,6 @@ from sqlobject import * +from sqlobject.col import validators from sqlobject.tests.dbtest import * -from formencode import Invalid ######################################## ## Enum test @@ -17,9 +17,10 @@ raises( (Enum1._connection.module.IntegrityError, Enum1._connection.module.ProgrammingError, - Invalid), + validators.Invalid), Enum1, l='b') + class EnumWithNone(SQLObject): l = EnumCol(enumValues=['a', 'bcd', 'e', None]) @@ -30,6 +31,7 @@ e = EnumWithNone(l=l) assert e.l == l + class EnumWithDefaultNone(SQLObject): l = EnumCol(enumValues=['a', 'bcd', 'e', None], default=None) @@ -40,6 +42,7 @@ e = EnumWithDefaultNone() assert e.l == None + class EnumWithDefaultOther(SQLObject): l = EnumCol(enumValues=['a', 'bcd', 'e', None], default='a') Modified: SQLObject/branches/1.5/sqlobject/tests/test_validation.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_validation.py Mon Aug 19 06:23:20 2013 (r4648) +++ SQLObject/branches/1.5/sqlobject/tests/test_validation.py Tue Aug 20 07:18:31 2013 (r4649) @@ -1,6 +1,6 @@ from sqlobject import * +from sqlobject.col import validators from sqlobject.tests.dbtest import * -from formencode import validators ######################################## ## Validation/conversion |
From: <sub...@co...> - 2013-08-19 12:23:27
|
Author: phd Date: Mon Aug 19 06:23:20 2013 New Revision: 4648 Log: Merged revision 4647 from branch 1.5: self.make_conn_str() returns either a str or a dict Modified: SQLObject/trunk/sqlobject/mssql/mssqlconnection.py Modified: SQLObject/trunk/sqlobject/mssql/mssqlconnection.py ============================================================================== --- SQLObject/trunk/sqlobject/mssql/mssqlconnection.py Mon Aug 19 06:21:40 2013 (r4647) +++ SQLObject/trunk/sqlobject/mssql/mssqlconnection.py Mon Aug 19 06:23:20 2013 (r4648) @@ -48,10 +48,10 @@ # MSDE does not allow SQL server login if kw.get("sspi"): conn_str += "Integrated Security=SSPI;Persist Security Info=False" - self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db)] + self.make_conn_str = lambda keys: conn_str % (keys.host, keys.db) else: conn_str += "User Id=%s;Password=%s" - self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db, keys.user, keys.password)] + self.make_conn_str = lambda keys: conn_str % (keys.host, keys.db, keys.user, keys.password) kw.pop("sspi", None) kw.pop("ncli", None) @@ -100,7 +100,11 @@ return c.fetchone()[0] def makeConnection(self): - con = self.dbconnection( *self.make_conn_str(self) ) + conn_descr = self.make_conn_str(self) + if isinstance(conn_descr, dict): + con = self.dbconnection(**conn_descr) + else: + con = self.dbconnection(conn_descr) cur = con.cursor() cur.execute('SET ANSI_NULLS ON') cur.execute("SELECT CAST('12345.21' AS DECIMAL(10, 2))") |
From: <sub...@co...> - 2013-08-19 12:21:48
|
Author: phd Date: Mon Aug 19 06:21:40 2013 New Revision: 4647 Log: self.make_conn_str() returns either a str or a dict Modified: SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py Modified: SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py Fri Aug 16 13:58:36 2013 (r4646) +++ SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py Mon Aug 19 06:21:40 2013 (r4647) @@ -48,10 +48,10 @@ # MSDE does not allow SQL server login if kw.get("sspi"): conn_str += "Integrated Security=SSPI;Persist Security Info=False" - self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db)] + self.make_conn_str = lambda keys: conn_str % (keys.host, keys.db) else: conn_str += "User Id=%s;Password=%s" - self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db, keys.user, keys.password)] + self.make_conn_str = lambda keys: conn_str % (keys.host, keys.db, keys.user, keys.password) kw.pop("sspi", None) kw.pop("ncli", None) @@ -100,7 +100,11 @@ return c.fetchone()[0] def makeConnection(self): - con = self.dbconnection( *self.make_conn_str(self) ) + conn_descr = self.make_conn_str(self) + if isinstance(conn_descr, dict): + con = self.dbconnection(**conn_descr) + else: + con = self.dbconnection(conn_descr) cur = con.cursor() cur.execute('SET ANSI_NULLS ON') cur.execute("SELECT CAST('12345.21' AS DECIMAL(10, 2))") |
From: <sub...@co...> - 2013-08-16 19:58:43
|
Author: phd Date: Fri Aug 16 13:58:36 2013 New Revision: 4646 Log: Merged revisions 4644, 4645 from branch 1.5: fixed parameters for pymssql Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/mssql/mssqlconnection.py Modified: SQLObject/trunk/docs/News.txt ============================================================================== --- SQLObject/trunk/docs/News.txt Fri Aug 16 13:57:20 2013 (r4645) +++ SQLObject/trunk/docs/News.txt Fri Aug 16 13:58:36 2013 (r4646) @@ -30,6 +30,8 @@ * A bug was fixed in DBConnection.close(); close() doesn't raise an UnboundLocalError if connection pool is empty. +* Fixed parameters for pymssql. + SQLObject 1.4.1 =============== Modified: SQLObject/trunk/sqlobject/mssql/mssqlconnection.py ============================================================================== --- SQLObject/trunk/sqlobject/mssql/mssqlconnection.py Fri Aug 16 13:57:20 2013 (r4645) +++ SQLObject/trunk/sqlobject/mssql/mssqlconnection.py Fri Aug 16 13:58:36 2013 (r4646) @@ -61,16 +61,25 @@ sqlmodule.Binary = lambda st: str(st) # don't know whether pymssql uses unicode self.usingUnicodeStrings = False - self.make_conn_str = lambda keys: \ - ["", keys.user, keys.password, keys.host, keys.db] + def _make_conn_str(keys): + keys_dict = {} + for attr, value in ( + ('user', keys.user), + ('password', keys.password), + ('host', keys.host), + ('port', keys.port), + ('database', keys.db), + ): + if value: keys_dict[attr] = value + return keys_dict + self.make_conn_str = _make_conn_str self.autoCommit=int(autoCommit) + self.user = user + self.password = password self.host = host self.port = port self.db = db - self.user = user - self.password = password - self.password = password self._can_use_max_types = None DBAPI.__init__(self, **kw) |
From: <sub...@co...> - 2013-08-16 19:57:26
|
Author: phd Date: Fri Aug 16 13:57:20 2013 New Revision: 4645 Log: Update News Modified: SQLObject/branches/1.5/docs/News.txt Modified: SQLObject/branches/1.5/docs/News.txt ============================================================================== --- SQLObject/branches/1.5/docs/News.txt Fri Aug 16 13:54:42 2013 (r4644) +++ SQLObject/branches/1.5/docs/News.txt Fri Aug 16 13:57:20 2013 (r4645) @@ -27,6 +27,8 @@ * A bug was fixed in DBConnection.close(); close() doesn't raise an UnboundLocalError if connection pool is empty. +* Fixed parameters for pymssql. + SQLObject 1.4.1 =============== |
From: <sub...@co...> - 2013-08-16 19:54:50
|
Author: phd Date: Fri Aug 16 13:54:42 2013 New Revision: 4644 Log: Fixed parameters for pymssql Modified: SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py Modified: SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py Fri Aug 16 13:36:32 2013 (r4643) +++ SQLObject/branches/1.5/sqlobject/mssql/mssqlconnection.py Fri Aug 16 13:54:42 2013 (r4644) @@ -61,16 +61,25 @@ sqlmodule.Binary = lambda st: str(st) # don't know whether pymssql uses unicode self.usingUnicodeStrings = False - self.make_conn_str = lambda keys: \ - ["", keys.user, keys.password, keys.host, keys.db] + def _make_conn_str(keys): + keys_dict = {} + for attr, value in ( + ('user', keys.user), + ('password', keys.password), + ('host', keys.host), + ('port', keys.port), + ('database', keys.db), + ): + if value: keys_dict[attr] = value + return keys_dict + self.make_conn_str = _make_conn_str self.autoCommit=int(autoCommit) + self.user = user + self.password = password self.host = host self.port = port self.db = db - self.user = user - self.password = password - self.password = password self._can_use_max_types = None DBAPI.__init__(self, **kw) |
From: <sub...@co...> - 2013-08-16 19:36:39
|
Author: phd Date: Fri Aug 16 13:36:32 2013 New Revision: 4643 Log: Merged revisions 4641, 4642 from branch 1.5: tests enhancements Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py SQLObject/trunk/sqlobject/tests/test_exceptions.py SQLObject/trunk/sqlobject/tests/test_groupBy.py SQLObject/trunk/sqlobject/tests/test_indexes.py SQLObject/trunk/sqlobject/tests/test_schema.py SQLObject/trunk/sqlobject/tests/test_select.py SQLObject/trunk/sqlobject/tests/test_unicode.py Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py ============================================================================== --- SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py Fri Aug 16 13:36:32 2013 (r4643) @@ -8,12 +8,12 @@ ######################################## class DIPerson(InheritableSQLObject): - firstName = StringCol() + firstName = StringCol(length=100) lastName = StringCol(alternateID=True, length=255) manager = ForeignKey("DIManager", default=None) class DIEmployee(DIPerson): - position = StringCol(unique=True) + position = StringCol(unique=True, length=100) class DIManager(DIEmployee): subdudes = MultipleJoin("DIPerson", joinColumn="manager_id") Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py ============================================================================== --- SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/inheritance/tests/test_indexes.py Fri Aug 16 13:36:32 2013 (r4643) @@ -4,8 +4,8 @@ class InheritedPersonIndexGet(InheritableSQLObject): - first_name = StringCol(notNone=True) - last_name = StringCol(notNone=True) + first_name = StringCol(notNone=True, length=100) + last_name = StringCol(notNone=True, length=100) age = IntCol() pk = DatabaseIndex(first_name, last_name, unique=True) Modified: SQLObject/trunk/sqlobject/tests/test_exceptions.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_exceptions.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/tests/test_exceptions.py Fri Aug 16 13:36:32 2013 (r4643) @@ -7,7 +7,7 @@ ######################################## class TestException(SQLObject): - name = StringCol(unique=True) + name = StringCol(unique=True, length=100) def test_exceptions(): if not supports("exceptions"): Modified: SQLObject/trunk/sqlobject/tests/test_groupBy.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_groupBy.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/tests/test_groupBy.py Fri Aug 16 13:36:32 2013 (r4643) @@ -22,7 +22,7 @@ orderBy=GroupbyTest.q.name) sql = connection.sqlrepr(select) rows = connection.queryAll(sql) - assert rows == [('a', 2), ('b', 1)] + assert list(rows) == [('a', 2), ('b', 1)] def test_groupBy_list(): setupClass(GroupbyTest) @@ -36,4 +36,4 @@ orderBy=[GroupbyTest.q.name, GroupbyTest.q.value]) sql = connection.sqlrepr(select) rows = connection.queryAll(sql) - assert rows == [('a', 1), ('a', 2), ('b', 1)] + assert list(rows) == [('a', 1), ('a', 2), ('b', 1)] Modified: SQLObject/trunk/sqlobject/tests/test_indexes.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_indexes.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/tests/test_indexes.py Fri Aug 16 13:36:32 2013 (r4643) @@ -15,7 +15,7 @@ nameIndex3 = DatabaseIndex({'column': name, 'length': 3}) class SOIndex2(SQLObject): - name = StringCol() + name = StringCol(length=100) nameIndex = DatabaseIndex({'expression': 'lower(name)'}) def test_indexes_1(): @@ -44,8 +44,8 @@ class PersonIndexGet(SQLObject): - firstName = StringCol() - lastName = StringCol() + firstName = StringCol(length=100) + lastName = StringCol(length=100) age = IntCol(alternateID=True) nameIndex = DatabaseIndex(firstName, lastName, unique=True) @@ -90,13 +90,13 @@ class PersonIndexGet2(SQLObject): - name = StringCol(alternateID=True) + name = StringCol(alternateID=True, length=100) age = IntCol() addresses = MultipleJoin('AddressIndexGet2') class AddressIndexGet2(SQLObject): person = ForeignKey('PersonIndexGet2', notNone=True) - type = StringCol(notNone=True) + type = StringCol(notNone=True, length=100) street = StringCol(notNone=True) pk = DatabaseIndex(person, type, unique=True) Modified: SQLObject/trunk/sqlobject/tests/test_schema.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_schema.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/tests/test_schema.py Fri Aug 16 13:36:32 2013 (r4643) @@ -5,7 +5,7 @@ ## Schema per connection ######################################## -class Test(SQLObject): +class TestSchema(SQLObject): foo = UnicodeCol(length=200) def test_connection_schema(): @@ -16,8 +16,9 @@ conn.query('CREATE SCHEMA test') conn.schema = 'test' conn.query('SET search_path TO test') - setupClass(Test) - Test(foo='bar') - assert conn.queryAll("SELECT * FROM test.test") + setupClass(TestSchema) + assert TestSchema._connection is conn + TestSchema(foo='bar') + assert conn.queryAll("SELECT * FROM test.test_schema") conn.schema = None conn.query('SET search_path TO public') Modified: SQLObject/trunk/sqlobject/tests/test_select.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_select.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/tests/test_select.py Fri Aug 16 13:36:32 2013 (r4643) @@ -5,7 +5,7 @@ from dbtest import setSQLiteConnectionFactory class IterTest(SQLObject): - name = StringCol(dbName='name_col') + name = StringCol(dbName='name_col', length=200) names = ('a', 'b', 'c') def setupIter(): @@ -113,7 +113,7 @@ assert False, "IterTest(nonexistant='b') should raise TypeError" class UniqTest(SQLObject): - name = StringCol(dbName='name_col', unique=True) + name = StringCol(dbName='name_col', unique=True, length=100) def test_by_uniq(): setupClass(UniqTest) Modified: SQLObject/trunk/sqlobject/tests/test_unicode.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_unicode.py Fri Aug 16 13:34:59 2013 (r4642) +++ SQLObject/trunk/sqlobject/tests/test_unicode.py Fri Aug 16 13:36:32 2013 (r4643) @@ -85,10 +85,6 @@ def test_dbEncoding(): setup() - assert TestUnicode.sqlmeta.dbEncoding is None - assert not hasattr(TestUnicode._connection, 'dbEncoding') or \ - TestUnicode._connection.dbEncoding is None - TestUnicode.sqlmeta.dbEncoding = 'utf-8' _test_select() TestUnicode.sqlmeta.dbEncoding = 'latin-1' @@ -104,3 +100,4 @@ TestUnicode._connection.dbEncoding = 'ascii' raises(UnicodeEncodeError, _test_select) del TestUnicode.sqlmeta.dbEncoding + TestUnicode._connection.dbEncoding = 'utf-8' |
From: <sub...@co...> - 2013-08-16 19:35:07
|
Author: phd Date: Fri Aug 16 13:34:59 2013 New Revision: 4642 Log: Patches from Neil Muller to run tests with MySQL Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py SQLObject/branches/1.5/sqlobject/inheritance/tests/test_indexes.py SQLObject/branches/1.5/sqlobject/tests/test_exceptions.py SQLObject/branches/1.5/sqlobject/tests/test_groupBy.py SQLObject/branches/1.5/sqlobject/tests/test_indexes.py SQLObject/branches/1.5/sqlobject/tests/test_select.py Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py Fri Aug 16 13:33:02 2013 (r4641) +++ SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py Fri Aug 16 13:34:59 2013 (r4642) @@ -8,12 +8,12 @@ ######################################## class DIPerson(InheritableSQLObject): - firstName = StringCol() + firstName = StringCol(length=100) lastName = StringCol(alternateID=True, length=255) manager = ForeignKey("DIManager", default=None) class DIEmployee(DIPerson): - position = StringCol(unique=True) + position = StringCol(unique=True, length=100) class DIManager(DIEmployee): subdudes = MultipleJoin("DIPerson", joinColumn="manager_id") Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_indexes.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/inheritance/tests/test_indexes.py Fri Aug 16 13:33:02 2013 (r4641) +++ SQLObject/branches/1.5/sqlobject/inheritance/tests/test_indexes.py Fri Aug 16 13:34:59 2013 (r4642) @@ -4,8 +4,8 @@ class InheritedPersonIndexGet(InheritableSQLObject): - first_name = StringCol(notNone=True) - last_name = StringCol(notNone=True) + first_name = StringCol(notNone=True, length=100) + last_name = StringCol(notNone=True, length=100) age = IntCol() pk = DatabaseIndex(first_name, last_name, unique=True) Modified: SQLObject/branches/1.5/sqlobject/tests/test_exceptions.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_exceptions.py Fri Aug 16 13:33:02 2013 (r4641) +++ SQLObject/branches/1.5/sqlobject/tests/test_exceptions.py Fri Aug 16 13:34:59 2013 (r4642) @@ -7,7 +7,7 @@ ######################################## class TestException(SQLObject): - name = StringCol(unique=True) + name = StringCol(unique=True, length=100) def test_exceptions(): if not supports("exceptions"): Modified: SQLObject/branches/1.5/sqlobject/tests/test_groupBy.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_groupBy.py Fri Aug 16 13:33:02 2013 (r4641) +++ SQLObject/branches/1.5/sqlobject/tests/test_groupBy.py Fri Aug 16 13:34:59 2013 (r4642) @@ -22,7 +22,7 @@ orderBy=GroupbyTest.q.name) sql = connection.sqlrepr(select) rows = connection.queryAll(sql) - assert rows == [('a', 2), ('b', 1)] + assert list(rows) == [('a', 2), ('b', 1)] def test_groupBy_list(): setupClass(GroupbyTest) @@ -36,4 +36,4 @@ orderBy=[GroupbyTest.q.name, GroupbyTest.q.value]) sql = connection.sqlrepr(select) rows = connection.queryAll(sql) - assert rows == [('a', 1), ('a', 2), ('b', 1)] + assert list(rows) == [('a', 1), ('a', 2), ('b', 1)] Modified: SQLObject/branches/1.5/sqlobject/tests/test_indexes.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_indexes.py Fri Aug 16 13:33:02 2013 (r4641) +++ SQLObject/branches/1.5/sqlobject/tests/test_indexes.py Fri Aug 16 13:34:59 2013 (r4642) @@ -15,7 +15,7 @@ nameIndex3 = DatabaseIndex({'column': name, 'length': 3}) class SOIndex2(SQLObject): - name = StringCol() + name = StringCol(length=100) nameIndex = DatabaseIndex({'expression': 'lower(name)'}) def test_indexes_1(): @@ -44,8 +44,8 @@ class PersonIndexGet(SQLObject): - firstName = StringCol() - lastName = StringCol() + firstName = StringCol(length=100) + lastName = StringCol(length=100) age = IntCol(alternateID=True) nameIndex = DatabaseIndex(firstName, lastName, unique=True) @@ -90,13 +90,13 @@ class PersonIndexGet2(SQLObject): - name = StringCol(alternateID=True) + name = StringCol(alternateID=True, length=100) age = IntCol() addresses = MultipleJoin('AddressIndexGet2') class AddressIndexGet2(SQLObject): person = ForeignKey('PersonIndexGet2', notNone=True) - type = StringCol(notNone=True) + type = StringCol(notNone=True, length=100) street = StringCol(notNone=True) pk = DatabaseIndex(person, type, unique=True) Modified: SQLObject/branches/1.5/sqlobject/tests/test_select.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_select.py Fri Aug 16 13:33:02 2013 (r4641) +++ SQLObject/branches/1.5/sqlobject/tests/test_select.py Fri Aug 16 13:34:59 2013 (r4642) @@ -5,7 +5,7 @@ from dbtest import setSQLiteConnectionFactory class IterTest(SQLObject): - name = StringCol(dbName='name_col') + name = StringCol(dbName='name_col', length=200) names = ('a', 'b', 'c') def setupIter(): @@ -113,7 +113,7 @@ assert False, "IterTest(nonexistant='b') should raise TypeError" class UniqTest(SQLObject): - name = StringCol(dbName='name_col', unique=True) + name = StringCol(dbName='name_col', unique=True, length=100) def test_by_uniq(): setupClass(UniqTest) |
From: <sub...@co...> - 2013-08-16 19:33:14
|
Author: phd Date: Fri Aug 16 13:33:02 2013 New Revision: 4641 Log: Minor changes for the case when all tests are running at once (not one by one) Modified: SQLObject/branches/1.5/sqlobject/tests/test_schema.py SQLObject/branches/1.5/sqlobject/tests/test_unicode.py Modified: SQLObject/branches/1.5/sqlobject/tests/test_schema.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_schema.py Wed Aug 14 11:16:03 2013 (r4640) +++ SQLObject/branches/1.5/sqlobject/tests/test_schema.py Fri Aug 16 13:33:02 2013 (r4641) @@ -5,7 +5,7 @@ ## Schema per connection ######################################## -class Test(SQLObject): +class TestSchema(SQLObject): foo = UnicodeCol(length=200) def test_connection_schema(): @@ -16,8 +16,9 @@ conn.query('CREATE SCHEMA test') conn.schema = 'test' conn.query('SET search_path TO test') - setupClass(Test) - Test(foo='bar') - assert conn.queryAll("SELECT * FROM test.test") + setupClass(TestSchema) + assert TestSchema._connection is conn + TestSchema(foo='bar') + assert conn.queryAll("SELECT * FROM test.test_schema") conn.schema = None conn.query('SET search_path TO public') Modified: SQLObject/branches/1.5/sqlobject/tests/test_unicode.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_unicode.py Wed Aug 14 11:16:03 2013 (r4640) +++ SQLObject/branches/1.5/sqlobject/tests/test_unicode.py Fri Aug 16 13:33:02 2013 (r4641) @@ -85,10 +85,6 @@ def test_dbEncoding(): setup() - assert TestUnicode.sqlmeta.dbEncoding is None - assert not hasattr(TestUnicode._connection, 'dbEncoding') or \ - TestUnicode._connection.dbEncoding is None - TestUnicode.sqlmeta.dbEncoding = 'utf-8' _test_select() TestUnicode.sqlmeta.dbEncoding = 'latin-1' @@ -104,3 +100,4 @@ TestUnicode._connection.dbEncoding = 'ascii' raises(UnicodeEncodeError, _test_select) del TestUnicode.sqlmeta.dbEncoding + TestUnicode._connection.dbEncoding = 'utf-8' |
From: <sub...@co...> - 2013-08-14 17:16:10
|
Author: phd Date: Wed Aug 14 11:16:03 2013 New Revision: 4640 Log: Merged revisions 4637-4639 from branch 1.5: logging is always available; on w32 there is no need to replace semicolon but it's recommended to straighten backslashes; removed unused workaround for old Python. Modified: SQLObject/trunk/sqlobject/tests/dbtest.py Modified: SQLObject/trunk/sqlobject/tests/dbtest.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/dbtest.py Wed Aug 14 11:14:24 2013 (r4639) +++ SQLObject/trunk/sqlobject/tests/dbtest.py Wed Aug 14 11:16:03 2013 (r4640) @@ -2,23 +2,17 @@ The framework for making database tests. """ -import sys +import logging import os import re +import sys from py.test import raises -import py import sqlobject import sqlobject.conftest as conftest -try: - import logging - loggingModuleAvailable = True -except ImportError: - loggingModuleAvailable = False - if sys.platform[:3] == "win": def getcwd(): - return os.getcwd().replace(':', '|') + return os.getcwd().replace('\\', '/') else: getcwd = os.getcwd @@ -222,13 +216,6 @@ for name, value in kw.items(): setattr(self, name, value) -def d(**kw): - """ - Because ``dict(**kw)`` doesn't work in Python 2.2, this is a - replacement. - """ - return kw - def inserts(cls, data, schema=None): """ Creates a bunch of rows. @@ -314,8 +301,6 @@ sqlobject.main.exception_level = 0 def setupLogging(): - if not loggingModuleAvailable: - return fmt = '[%(asctime)s] %(name)s %(levelname)s: %(message)s' formatter = logging.Formatter(fmt) hdlr = logging.StreamHandler(sys.stderr) @@ -325,5 +310,5 @@ logger.addHandler(hdlr) __all__ = ['getConnection', 'getConnectionURI', 'setupClass', 'Dummy', 'raises', - 'd', 'inserts', 'supports', 'deprecated_module', + 'inserts', 'supports', 'deprecated_module', 'setup_module', 'teardown_module', 'setupLogging'] |
From: <sub...@co...> - 2013-08-14 17:14:33
|
Author: phd Date: Wed Aug 14 11:14:24 2013 New Revision: 4639 Log: Removed unused workaround for old Python Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 11:11:12 2013 (r4638) +++ SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 11:14:24 2013 (r4639) @@ -216,13 +216,6 @@ for name, value in kw.items(): setattr(self, name, value) -def d(**kw): - """ - Because ``dict(**kw)`` doesn't work in Python 2.2, this is a - replacement. - """ - return kw - def inserts(cls, data, schema=None): """ Creates a bunch of rows. @@ -317,5 +310,5 @@ logger.addHandler(hdlr) __all__ = ['getConnection', 'getConnectionURI', 'setupClass', 'Dummy', 'raises', - 'd', 'inserts', 'supports', 'deprecated_module', + 'inserts', 'supports', 'deprecated_module', 'setup_module', 'teardown_module', 'setupLogging'] |
From: <sub...@co...> - 2013-08-14 17:11:22
|
Author: phd Date: Wed Aug 14 11:11:12 2013 New Revision: 4638 Log: On w32 there is no need to replace semicolon but it's recommended to straighten backslashes Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 11:08:42 2013 (r4637) +++ SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 11:11:12 2013 (r4638) @@ -12,7 +12,7 @@ if sys.platform[:3] == "win": def getcwd(): - return os.getcwd().replace(':', '|') + return os.getcwd().replace('\\', '/') else: getcwd = os.getcwd |
From: <sub...@co...> - 2013-08-14 17:08:52
|
Author: phd Date: Wed Aug 14 11:08:42 2013 New Revision: 4637 Log: logging is always available -- SQLObject requires at least Python 2.4 Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 09:19:06 2013 (r4636) +++ SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 11:08:42 2013 (r4637) @@ -2,20 +2,14 @@ The framework for making database tests. """ -import sys +import logging import os import re +import sys from py.test import raises -import py import sqlobject import sqlobject.conftest as conftest -try: - import logging - loggingModuleAvailable = True -except ImportError: - loggingModuleAvailable = False - if sys.platform[:3] == "win": def getcwd(): return os.getcwd().replace(':', '|') @@ -314,8 +308,6 @@ sqlobject.main.exception_level = 0 def setupLogging(): - if not loggingModuleAvailable: - return fmt = '[%(asctime)s] %(name)s %(levelname)s: %(message)s' formatter = logging.Formatter(fmt) hdlr = logging.StreamHandler(sys.stderr) |
From: <sub...@co...> - 2013-08-14 15:19:15
|
Author: phd Date: Wed Aug 14 09:19:06 2013 New Revision: 4636 Log: Merged revision 4635 from branch 1.5: test fixes by Neil Muller Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_asdict.py SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py SQLObject/trunk/sqlobject/tests/dbtest.py SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py SQLObject/trunk/sqlobject/tests/test_schema.py SQLObject/trunk/sqlobject/tests/test_transactions.py Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_asdict.py ============================================================================== --- SQLObject/trunk/sqlobject/inheritance/tests/test_asdict.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/inheritance/tests/test_asdict.py Wed Aug 14 09:19:06 2013 (r4636) @@ -29,7 +29,7 @@ assert _columns == columns def test_asDict(): - setupClass([InheritablePersonAD, ManagerAD, EmployeeAD]) + setupClass([InheritablePersonAD, ManagerAD, EmployeeAD], force=True) InheritablePersonAD(firstName='Oneof', lastName='Authors') ManagerAD(firstName='ManagerAD', lastName='The', department='Dep') EmployeeAD(firstName='Project', lastName='Leader', position='Project leader') Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py ============================================================================== --- SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py Wed Aug 14 09:19:06 2013 (r4636) @@ -72,7 +72,8 @@ person_id = DIPerson(firstName='Oneof', lastName='Authors', manager=manager).id - cache = getConnection().cache + conn = getConnection() + cache = conn.cache cache.clear() managers = list(DIManager.select()) @@ -97,3 +98,4 @@ person = DIEmployee.get(manager_id) assert isinstance(person, DIManager) + conn.close() Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py ============================================================================== --- SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/inheritance/tests/test_foreignKey.py Wed Aug 14 09:19:06 2013 (r4636) @@ -19,7 +19,7 @@ paper = ForeignKey("Paper", default=None) def test_foreignKey(): - setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes]) + setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes], force=True) note = Note(text="person") PersonWithNotes(firstName='Oneof', lastName='Authors', note=note) Modified: SQLObject/trunk/sqlobject/tests/dbtest.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/dbtest.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/tests/dbtest.py Wed Aug 14 09:19:06 2013 (r4636) @@ -40,7 +40,7 @@ supportsMatrix = { '+exceptions': 'mysql postgres sqlite', '-transactions': 'mysql rdbhost', - '-dropTableCascade': 'sybase mssql', + '-dropTableCascade': 'sybase mssql mysql', '-expressionIndex': 'mysql sqlite firebird mssql', '-blobData': 'mssql rdbhost', '-decimalColumn': 'mssql', Modified: SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py Wed Aug 14 09:19:06 2013 (r4636) @@ -24,6 +24,8 @@ fkeya = ForeignKey('TestCyclicReferenceA') def test_cyclic_reference(): + if not supports('dropTableCascade'): + return conn = getConnection() TestCyclicReferenceA.setConnection(conn) TestCyclicReferenceB.setConnection(conn) Modified: SQLObject/trunk/sqlobject/tests/test_schema.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_schema.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/tests/test_schema.py Wed Aug 14 09:19:06 2013 (r4636) @@ -19,3 +19,5 @@ setupClass(Test) Test(foo='bar') assert conn.queryAll("SELECT * FROM test.test") + conn.schema = None + conn.query('SET search_path TO public') Modified: SQLObject/trunk/sqlobject/tests/test_transactions.py ============================================================================== --- SQLObject/trunk/sqlobject/tests/test_transactions.py Wed Aug 14 09:15:14 2013 (r4635) +++ SQLObject/trunk/sqlobject/tests/test_transactions.py Wed Aug 14 09:19:06 2013 (r4636) @@ -75,6 +75,7 @@ finally: trans.rollback() connection.autoCommit = True + connection.close() def test_transaction_delete_with_close(): test_transaction_delete(close=True) |
From: <sub...@co...> - 2013-08-14 15:15:23
|
Author: phd Date: Wed Aug 14 09:15:14 2013 New Revision: 4635 Log: Another couple of test fixes by Neil Muller sqlobject/tests/test_schema.py: clear schema so later tests don't fail. sqlobject/tests/test_transactions.py: close connection. Without this, test_unicode fails if part of the same run. sqlobject/inheritance/tests/test_deep_inheritance.py: close connection. Without this, several tests (such as test_schema) fail if included in the same run. sqlobject/inheritance/tests/test_foreignKey.py: force recreating tables to prevent problems on subsequent runs with the same database. sqlobject/tests/dbtest.py, sqlobject/tests/test_cyclic_reference.py: skip the test on MySQL because it doesn't support 'DROP TABLE .. CASCADE. Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py SQLObject/branches/1.5/sqlobject/inheritance/tests/test_foreignKey.py SQLObject/branches/1.5/sqlobject/tests/dbtest.py SQLObject/branches/1.5/sqlobject/tests/test_cyclic_reference.py SQLObject/branches/1.5/sqlobject/tests/test_schema.py SQLObject/branches/1.5/sqlobject/tests/test_transactions.py Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py Wed Aug 14 09:15:14 2013 (r4635) @@ -29,7 +29,7 @@ assert _columns == columns def test_asDict(): - setupClass([InheritablePersonAD, ManagerAD, EmployeeAD]) + setupClass([InheritablePersonAD, ManagerAD, EmployeeAD], force=True) InheritablePersonAD(firstName='Oneof', lastName='Authors') ManagerAD(firstName='ManagerAD', lastName='The', department='Dep') EmployeeAD(firstName='Project', lastName='Leader', position='Project leader') Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/inheritance/tests/test_deep_inheritance.py Wed Aug 14 09:15:14 2013 (r4635) @@ -72,7 +72,8 @@ person_id = DIPerson(firstName='Oneof', lastName='Authors', manager=manager).id - cache = getConnection().cache + conn = getConnection() + cache = conn.cache cache.clear() managers = list(DIManager.select()) @@ -97,3 +98,4 @@ person = DIEmployee.get(manager_id) assert isinstance(person, DIManager) + conn.close() Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_foreignKey.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/inheritance/tests/test_foreignKey.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/inheritance/tests/test_foreignKey.py Wed Aug 14 09:15:14 2013 (r4635) @@ -19,7 +19,7 @@ paper = ForeignKey("Paper", default=None) def test_foreignKey(): - setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes]) + setupClass([Note, PersonWithNotes, Paper, EmployeeWithNotes], force=True) note = Note(text="person") PersonWithNotes(firstName='Oneof', lastName='Authors', note=note) Modified: SQLObject/branches/1.5/sqlobject/tests/dbtest.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/dbtest.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/tests/dbtest.py Wed Aug 14 09:15:14 2013 (r4635) @@ -40,7 +40,7 @@ supportsMatrix = { '+exceptions': 'mysql postgres sqlite', '-transactions': 'mysql rdbhost', - '-dropTableCascade': 'sybase mssql', + '-dropTableCascade': 'sybase mssql mysql', '-expressionIndex': 'mysql sqlite firebird mssql', '-blobData': 'mssql rdbhost', '-decimalColumn': 'mssql', Modified: SQLObject/branches/1.5/sqlobject/tests/test_cyclic_reference.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_cyclic_reference.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/tests/test_cyclic_reference.py Wed Aug 14 09:15:14 2013 (r4635) @@ -24,6 +24,8 @@ fkeya = ForeignKey('TestCyclicReferenceA') def test_cyclic_reference(): + if not supports('dropTableCascade'): + return conn = getConnection() TestCyclicReferenceA.setConnection(conn) TestCyclicReferenceB.setConnection(conn) Modified: SQLObject/branches/1.5/sqlobject/tests/test_schema.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_schema.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/tests/test_schema.py Wed Aug 14 09:15:14 2013 (r4635) @@ -19,3 +19,5 @@ setupClass(Test) Test(foo='bar') assert conn.queryAll("SELECT * FROM test.test") + conn.schema = None + conn.query('SET search_path TO public') Modified: SQLObject/branches/1.5/sqlobject/tests/test_transactions.py ============================================================================== --- SQLObject/branches/1.5/sqlobject/tests/test_transactions.py Mon Aug 12 08:22:56 2013 (r4634) +++ SQLObject/branches/1.5/sqlobject/tests/test_transactions.py Wed Aug 14 09:15:14 2013 (r4635) @@ -75,6 +75,7 @@ finally: trans.rollback() connection.autoCommit = True + connection.close() def test_transaction_delete_with_close(): test_transaction_delete(close=True) |