Skip to content

Commit

Permalink
Added SQLAlchemy 1.0 support, dropped support for 0.7 and 0.8 versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmagamedov committed May 23, 2015
1 parent e470353 commit 07fc1bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 43 deletions.
10 changes: 8 additions & 2 deletions sqlconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

_SQLA_ge_09 = sqlalchemy.__version__ >= '0.9'

_SQLA_ge_10 = sqlalchemy.__version__ >= '1.0'


if _PY3:
import builtins
Expand Down Expand Up @@ -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


Expand Down
10 changes: 2 additions & 8 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]))
Expand Down
48 changes: 15 additions & 33 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07fc1bd

Please sign in to comment.