diff --git a/sqlconstruct.py b/sqlconstruct.py index 0692103..cef23f9 100644 --- a/sqlconstruct.py +++ b/sqlconstruct.py @@ -54,6 +54,8 @@ _SQLA_ge_09 = sqlalchemy.__version__ >= '0.9' +_SQLA_ge_10 = sqlalchemy.__version__ >= '1.0' + if _PY3: import builtins @@ -567,8 +569,12 @@ def from_query(self, query): return list(self._from_row(row) for row in query) def create_row_processor(self, query, procs, labels): - def proc(row, result): - return self._from_row([proc(row, None) for proc in procs]) + if _SQLA_ge_10: + def proc(row): + return self._from_row([proc(row) for proc in procs]) + else: + def proc(row, result): + return self._from_row([proc(row, None) for proc in procs]) return proc diff --git a/tests.py b/tests.py index 9ff0aef..dacc577 100644 --- a/tests.py +++ b/tests.py @@ -40,11 +40,6 @@ else: _range = xrange -if SQLA_ge_08: - from sqlalchemy.util import KeyedTuple -else: - from sqlalchemy.util import NamedTuple as KeyedTuple - from sqlconstruct import Construct, Object, apply_, if_, define, QueryMixin from sqlconstruct import ConstructQuery, bind, map_, get_, _Scope, _QueryPlan @@ -119,7 +114,6 @@ def setUp(self): def test_object_interface(self): obj = Object({'a': 1, 'b': 2}) - self.assertEqual(repr(obj), 'Object({})'.format(repr({'a': 1, 'b': 2}))) self.assertTrue(isinstance(obj, collections.Mapping), type(obj)) self.assertEqual(obj.a, 1) self.assertEqual(obj['a'], 1) @@ -466,14 +460,14 @@ def test_query_row(self): r1, r2 = query.all() - self.assertTrue(isinstance(r1, KeyedTuple), type(r1)) + self.assertTrue(isinstance(r1, tuple), type(r1)) self.assertEqual(r1.id, 1) self.assertEqual(r1.name, 'a1') self.assertTrue(isinstance(r1[1], Object), type(r1[1])) self.assertEqual(r1[1].a_id, 1) self.assertEqual(r1[1].a_name, 'a1') - self.assertTrue(isinstance(r2, KeyedTuple), type(r2)) + self.assertTrue(isinstance(r2, tuple), type(r2)) self.assertEqual(r2.id, 2) self.assertEqual(r2.name, 'a2') self.assertTrue(isinstance(r2[1], Object), type(r2[1])) diff --git a/tox.ini b/tox.ini index fc93825..bd443de 100644 --- a/tox.ini +++ b/tox.ini @@ -2,71 +2,53 @@ commands = python -m unittest tests -[testenv:py27sqla07] +[testenv:py27sqla-09] basepython = python2.7 deps = mock - https://github.com/zzzeek/sqlalchemy/archive/rel_0_7.zip + https://github.com/zzzeek/sqlalchemy/archive/rel_0_9.zip -[testenv:py27sqla08] +[testenv:py27sqla-10] basepython = python2.7 deps = mock - https://github.com/zzzeek/sqlalchemy/archive/rel_0_8.zip + https://github.com/zzzeek/sqlalchemy/archive/rel_1_0.zip -[testenv:py27sqla09] -basepython = python2.7 -deps = - mock - https://github.com/zzzeek/sqlalchemy/archive/rel_0_9.zip - -[testenv:py27sqlaXX] +[testenv:py27sqla-dev] basepython = python2.7 deps = mock https://github.com/zzzeek/sqlalchemy/archive/master.zip - -[testenv:py34sqla07] -basepython = python3.4 -deps = - https://github.com/zzzeek/sqlalchemy/archive/rel_0_7.zip - -[testenv:py34sqla08] +[testenv:py34sqla-09] basepython = python3.4 deps = - https://github.com/zzzeek/sqlalchemy/archive/rel_0_8.zip + https://github.com/zzzeek/sqlalchemy/archive/rel_0_9.zip -[testenv:py34sqla09] +[testenv:py34sqla-10] basepython = python3.4 deps = - https://github.com/zzzeek/sqlalchemy/archive/rel_0_9.zip + https://github.com/zzzeek/sqlalchemy/archive/rel_1_0.zip -[testenv:py34sqlaXX] +[testenv:py34sqla-dev] basepython = python3.4 deps = https://github.com/zzzeek/sqlalchemy/archive/master.zip -[testenv:pypysqla07] +[testenv:pypysqla-09] basepython = pypy deps = mock - https://github.com/zzzeek/sqlalchemy/archive/rel_0_7.zip - -[testenv:pypysqla08] -basepython = pypy -deps = - mock - https://github.com/zzzeek/sqlalchemy/archive/rel_0_8.zip + https://github.com/zzzeek/sqlalchemy/archive/rel_0_9.zip -[testenv:pypysqla09] +[testenv:pypysqla-10] basepython = pypy deps = mock - https://github.com/zzzeek/sqlalchemy/archive/rel_0_9.zip + https://github.com/zzzeek/sqlalchemy/archive/rel_1_0.zip -[testenv:pypysqlaXX] +[testenv:pypysqla-dev] basepython = pypy deps = mock