Skip to content

✨ Support SQLAlchemy keyed dict models #1287

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Use Dict[] instead of dict[]
  • Loading branch information
Natarajan Krishnaswami committed Feb 7, 2025
commit 563886a03e7e5e87af95a2f7ee4c079f3127ed3d
4 changes: 2 additions & 2 deletions tests/test_attribute_keyed_dict.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Optional
from typing import Dict, Optional

from sqlalchemy.orm.collections import attribute_keyed_dict
from sqlmodel import Field, Index, Relationship, Session, SQLModel, create_engine
@@ -25,7 +25,7 @@ class Parent(SQLModel, table=True):
__tablename__ = "parents"

id: Optional[int] = Field(primary_key=True, default=None)
children_by_color: dict[Color, Child] = Relationship(
children_by_color: Dict[Color, Child] = Relationship(
sa_relationship_kwargs={"collection_class": attribute_keyed_dict("color")}
)