Skip to content

Commit

Permalink
Merge pull request #79 from evo-company/basic-support-sqlalchemy1.4
Browse files Browse the repository at this point in the history
basic support for sqlalchemy1.4
  • Loading branch information
kindermax committed Aug 19, 2022
2 parents 257f470 + e5d9d50 commit c6c9065
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
10 changes: 8 additions & 2 deletions hiku/sources/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
)

import sqlalchemy
from sqlalchemy.engine import RowProxy
from sqlalchemy.sql import Select
from sqlalchemy.sql.elements import BinaryExpression

Expand All @@ -36,6 +35,13 @@
Context,
)

SQLALCHEMY_VERSION = tuple(map(int, sqlalchemy.__version__.split('.')))

if SQLALCHEMY_VERSION >= (1, 4):
from sqlalchemy.engine.row import Row
else:
from sqlalchemy.engine import RowProxy as Row


def _translate_type(
column: sqlalchemy.Column
Expand Down Expand Up @@ -104,7 +110,7 @@ def select_expr(
.where(self.in_impl(self.primary_key, ids))
)

def result_proc(rows: List[RowProxy]) -> List:
def result_proc(rows: List[Row]) -> List:
rows_map = {row[self.primary_key]: [row[c] for c in columns]
for row in rows}

Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
graphql-core
sqlalchemy
sqlalchemy>=1.3.9
protobuf
aiopg
prometheus-client
Expand Down
11 changes: 9 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
[tox]
envlist = py37,pypy3,py38,py39,py310
envlist = py37,pypy3,py38,py39,py310,py310_sqlalchemy14

[testenv]
commands = py.test tests {posargs}
deps = -r requirements-tox.txt

[testenv:py310_sqlalchemy14]
deps =
-r requirements-tox.txt
commands =
pip install sqlalchemy==1.4.40
py.test tests {posargs}

[testenv:flake8]
commands = flake8
deps = flake8==5.0.3
Expand Down Expand Up @@ -36,7 +43,7 @@ python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.10: py310,py310_sqlalchemy14

[coverage:run]
branch = True
Expand Down

0 comments on commit c6c9065

Please sign in to comment.