Skip to content

Commit 946c21f

Browse files
Copilotnomeguy
andcommitted
Fix SQLAlchemy version compatibility to support both 1.4.x and 2.x
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent 1c17ab4 commit 946c21f

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SQLAlchemy==1.4.42
1+
SQLAlchemy>=1.4.42
22
asynccasbin==1.1.7
3-
databases==0.7.0
3+
databases>=0.7.0

casbin_databases_adapter/adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def load_policy(self, model: Model):
2929
for row in rows:
3030
# convert row from tuple to csv format and removing the first column (id)
3131
line = [
32-
v for k, v in row._mapping.items() if k in self.cols and v is not None
32+
v for k, v in dict(row._mapping).items() if k in self.cols and v is not None
3333
]
3434
persist.load_policy_line(", ".join(line), model)
3535

@@ -84,7 +84,7 @@ async def load_filtered_policy(self, model: Model, filter_: Filter) -> None:
8484
for row in rows:
8585
# convert row from tuple to csv format and removing the first column (id)
8686
line = [
87-
v for k, v in row._mapping.items() if k in self.cols and v is not None
87+
v for k, v in dict(row._mapping).items() if k in self.cols and v is not None
8888
]
8989
persist.load_policy_line(", ".join(line), model)
9090

requirements-test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
asynccasbin==1.1.7
2-
databases==0.7.0
3-
SQLAlchemy==1.4.42
2+
databases>=0.7.0
3+
SQLAlchemy>=1.4.42
44
pytest>=7.3.0
55
pytest-asyncio>=1.1.0
66
aiosqlite>=0.19.0

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
asynccasbin==1.1.7
2-
databases==0.7.0
3-
SQLAlchemy==1.4.42
2+
databases>=0.7.0
3+
SQLAlchemy>=1.4.42

0 commit comments

Comments
 (0)