From e76654a3d1ea6f8699c8bb6157ff5f7cd4f96c34 Mon Sep 17 00:00:00 2001 From: JimmyYeh Date: Thu, 29 Feb 2024 15:54:55 +0800 Subject: [PATCH 1/2] Replace declarative_base -> DeclarativeBase for sqlalchemy 2.0 migration --- casbin_sqlalchemy_adapter/adapter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/casbin_sqlalchemy_adapter/adapter.py b/casbin_sqlalchemy_adapter/adapter.py index 6dc3200..8504847 100644 --- a/casbin_sqlalchemy_adapter/adapter.py +++ b/casbin_sqlalchemy_adapter/adapter.py @@ -3,10 +3,11 @@ from casbin import persist from sqlalchemy import Column, Integer, String from sqlalchemy import create_engine, or_ -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import sessionmaker, DeclarativeBase -Base = declarative_base() +# declarative base class +class Base(DeclarativeBase): + pass class CasbinRule(Base): @@ -288,3 +289,4 @@ def _update_filtered_policies(self, new_rules, filter) -> [[str]]: # return deleted rules return old_rules + From f80c5b0e0dc4a5219f1d19101ae895da4ca435e8 Mon Sep 17 00:00:00 2001 From: Eric Luo Date: Fri, 1 Mar 2024 09:24:10 +0800 Subject: [PATCH 2/2] Update adapter.py --- casbin_sqlalchemy_adapter/adapter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/casbin_sqlalchemy_adapter/adapter.py b/casbin_sqlalchemy_adapter/adapter.py index 8504847..d4fc239 100644 --- a/casbin_sqlalchemy_adapter/adapter.py +++ b/casbin_sqlalchemy_adapter/adapter.py @@ -289,4 +289,3 @@ def _update_filtered_policies(self, new_rules, filter) -> [[str]]: # return deleted rules return old_rules -