SQLAlchemy-Continuum compatibility #1954
Replies: 9 comments
-
|
For what it's worth, I am seeing this error even without sqlmodel or sqlalchemy_continuum. Did you ever find the root cause? |
Beta Was this translation helpful? Give feedback.
-
|
@petyunchik were you able to get this working? upgrading pydantic fixes that issue, however, there are a couple other issues that then you have to work through, both with continuum and sqlmodel |
Beta Was this translation helpful? Give feedback.
-
|
As of today (i.e. sqlmodel 0.0.14 and sqlalchemy-continuum 1.4.0), the error is Couldn't debug it properly, but I assume this is due to the fact that continuum create sqlalchemy models for versioning, but do not annotate these models. I think I'll have to deal with this problem, because versioning is of the essence for some of my applications. My intuition tells that it is best to create a new module by patching sqlalchemy-continuum to use sqlmodel's Base and registry, rather than adapting any of these to use the other |
Beta Was this translation helpful? Give feedback.
-
|
@ftapajos thank you for the suggestion. Any update on this? I am interested in contributing 🙏 |
Beta Was this translation helpful? Give feedback.
-
|
Related: sqlalchemy-continuum/sqlalchemy-continuum#271 @tiangolo any thoughts on this would be greatly appreciated! 🙏 |
Beta Was this translation helpful? Give feedback.
-
|
@abrichr I haven't even started yet, but I could follow your lead |
Beta Was this translation helpful? Give feedback.
-
|
Really hoping a solution is in the works here. |
Beta Was this translation helpful? Give feedback.
-
|
Can't wait to be compatible. I really need this feature. |
Beta Was this translation helpful? Give feedback.
-
|
I found a solution. I'm currently using: Before declaring any model, do the following: This should work with SQLModels. Your models should inherit from BaseSQLModel. If you use SQL Server as your database, you may encounter an error due to a sequence definition in the id column of the TransactionClass. You can rewrite the TransactionClass as shown below to address this issue. Additionally, I use a FastAPIPlugin to retrieve the user from the session. All you need to do is set the user data in the session.info dictionary. Here is the complete code I use: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Very basic setup of SQLAlchemy-Continuum doesn't work with SQLModel. Following error raised (see here):
SQLModelclass misses some expected attribute (registryfor SQLAlchemy >= 1.4) from SQLAlchemy'sBase. For debugging purposes the attribute can be manually populated (uncomment# setattr(SQLModel, 'registry', default_registry)in the example code) and it helps to proceed to the next error:Looks like there is some incompatibility with SQLAlchemy's expected behaviour, because this error was thrown just after SQLModel's
__new__method call.Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions