Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQLAlchemy list types #2668

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion reflex/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Any,
Callable,
Iterable,
List,
Literal,
Optional,
Type,
Expand Down Expand Up @@ -164,7 +165,11 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
prop = descriptor.property
if not isinstance(prop, Relationship):
return None
return prop.mapper.class_
class_ = prop.mapper.class_
if prop.uselist:
return List[class_]
else:
return class_
elif isinstance(cls, type) and issubclass(cls, Model):
# Check in the annotations directly (for sqlmodel.Relationship)
hints = get_type_hints(cls)
Expand Down
Loading