Преглед на файлове

support parsing type args of DeclarativeBase subclasses (#2348)

benedikt-bartscher преди 1 година
родител
ревизия
58a7e5e460
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      reflex/utils/types.py

+ 2 - 2
reflex/utils/types.py

@@ -19,7 +19,7 @@ from typing import (
 )
 
 from pydantic.fields import ModelField
-from sqlalchemy.orm import Mapped
+from sqlalchemy.orm import DeclarativeBase, Mapped
 
 from reflex.base import Base
 from reflex.utils import serializers
@@ -128,7 +128,7 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
             # Ensure frontend uses null coalescing when accessing.
             type_ = Optional[type_]
         return type_
-    elif isinstance(cls, type) and issubclass(cls, Model):
+    elif isinstance(cls, type) and issubclass(cls, (Model, DeclarativeBase)):
         # Check in the annotations directly (for sqlmodel.Relationship)
         hints = get_type_hints(cls)
         if name in hints: