You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sqlalchemy.exc.InvalidRequestError - using BaseModel
sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper...]' has no property ... If this property was indicated from other mappers or configure events, ensure registry.configure() has been called.
I get the following error: \sqlalchemy\orm\mapper.py", line 2507, in get_property raise sa_exc.InvalidRequestError( sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper[Task(task)]' has no property 'status'. If this property was indicated from other mappers or configure events, ensure registry.configure() has been called.
Bad workaround
If i remove the table=True attribute from Status it works fine. But i need the model to be in the database as well, thats were it gets tricky.
If i move the Relationship attribute from TaskBase to Task it works fine as well. But thats not ideal because later i want TaskCreate and TaskRead models, which will not be possible.
This is the best workaround i could find. So I can create derived Task.. models and have the Status as a db table.
Here i use a class StatusBase(SQLModel) and Status(
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First Check
Commit to Help
Example Code
Description
sqlalchemy.exc.InvalidRequestError - using BaseModel
sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper...]' has no property ... If this property was indicated from other mappers or configure events, ensure registry.configure() has been called.
Bug
This code does not work.
If i add something (doesn't matter which type):
I get the following error:
\sqlalchemy\orm\mapper.py", line 2507, in get_property raise sa_exc.InvalidRequestError( sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper[Task(task)]' has no property 'status'. If this property was indicated from other mappers or configure events, ensure registry.configure() has been called.
Bad workaround
If i remove the table=True attribute from Status it works fine. But i need the model to be in the database as well, thats were it gets tricky.
If i move the Relationship attribute from TaskBase to Task it works fine as well. But thats not ideal because later i want TaskCreate and TaskRead models, which will not be possible.
Best solution
This is the best workaround i could find. So I can create derived Task.. models and have the Status as a db table.
Here i use a class StatusBase(SQLModel) and Status(
Operating System
Windows
Operating System Details
Windows 11
SQLModel Version
0.0.12
Python Version
3.11
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions