ValueError: <class 'list'> has no matching SQLAlchemy type #995
Unanswered
mockingjet
asked this question in
Questions
Replies: 1 comment
-
I've tried to reproduce your example but couldn't. If I run your example verbatim, it errors with from sqlmodel import Field, Relationship, SQLModel
class RolePermissionLink(SQLModel, table=True):
role_id: str = Field(foreign_key="role.id", primary_key=True)
permission_id: str = Field(foreign_key="permission.id", primary_key=True)
class Role(SQLModel, table=True):
id: int = Field(primary_key=True)
name: str = Field(index=True, unique=True)
permissions: list["Permission"] = Relationship(
back_populates="roles",
link_model=RolePermissionLink,
)
class Permission(SQLModel, table=True):
id: int = Field(primary_key=True)
name: str = Field(index=True, unique=True)
roles: list[Role] = Relationship(
back_populates="permissions",
link_model=RolePermissionLink,
) ... then it works fine (no console output). Footnotes |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
Either
permissions: list["Permission"]
orroles: list[Role]
is not working and emits this error:Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.18
Python Version
3.12.4
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions