Error initializing relations in mapper when compiled with Cython #771
Unanswered
kevinkupski
asked this question in
Questions
Replies: 3 comments 2 replies
-
This seems to be a problem related to a new(er) release of sqlalchemy, But this still did not solve the problem for me. Looking for any help. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Same issue with cython and works well with cPython. any workaround here for this issue? |
Beta Was this translation helpful? Give feedback.
0 replies
-
What helped in my case was supplying the from sqlalchemy.orm import Mapped, relationship
...
heroes: Mapped[list[Message]] = Relationship(sa_relationship=relationship(back_populates="team")) |
Beta Was this translation helpful? Give feedback.
2 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
When compiling and running my SQLModel Code with Cython, I get the following error:
sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper[Document(documents)], expression "relationship("Optional['Collection']")" seems to be using a generic class as the argument to relationship(); please state the generic argument using an annotation, e.g. "collection: Mapped[Optional['Collection']] = relationship()"
Changing the code to the proposed
collection: Mapped[Optional['Collection']]
does not help.When using the code with the Python interpreter, it just works fine.
Operating System
Linux
Operating System Details
Running this code via the Devcontainer Extension of VSCode, which means I'm running it in Docker for Mac.
SQLModel Version
0.0.14
Python Version
3.11.7
Additional Context
Cython Version: 3.0.7
Beta Was this translation helpful? Give feedback.
All reactions