Skip to content

SQLModel support & tests - #363

Closed
mksh wants to merge 2 commits into
sqlalchemy-continuum:mainfrom
mksh:sqlmodel
Closed

mksh wants to merge 2 commits into
sqlalchemy-continuum:mainfrom
mksh:sqlmodel

Conversation

@mksh

@mksh mksh commented Apr 28, 2025

Copy link
Copy Markdown

Add support for models configured via https://github.com/fastapi/sqlmodel

As of current SQLModel/SQLAlchemy/SQLAlchemy-Continuum API, there is no need to depend on SQLModel to support it, as only change needed is to make SQLAlchemy-Continuum to pull SQLAlchemy class registry from different attribute for SQLModel derived models as compared to pure SQLAlchemy defined ones.

The base_classes parameter for versioned models does not work with SQLModel, pydantic metaclass magic fails for version model classes created with base_classes passed, because they are lacking __module__ attribute somehow, leading to AttributeError inside pydantic meta methods. Since I do not use base_classes in my projects, I decided not to put effort to support it in this patch, but future support might need changes in either SQLModel or pydantic.

Otherwise, most of stuff seem to work well, ported CRUD and relationships tests to run with SQLModel defined models as part of this PR.

I'd like to say thanks to https://github.com/AlePiccin who suggested the idea behind this PR implementation here: #271 (comment)

@mksh mksh mentioned this pull request Apr 28, 2025
@mksh

mksh commented Apr 28, 2025

Copy link
Copy Markdown
Author

I see tests are failed now on postgres non-native, will do some force-pushes of fix commit to my branch to reconcile them

@mksh

mksh commented Apr 28, 2025

Copy link
Copy Markdown
Author

@karol-tomala

Copy link
Copy Markdown

Could this be merged? Seems very useful

@mksh

mksh commented Oct 1, 2025

Copy link
Copy Markdown
Author

I see great improvements in 1.5.0 release, had rebased my fork and this PR on top of them. Sqlmodel is now optional dependency on par with other extras.

@mksh
mksh force-pushed the sqlmodel branch 2 times, most recently from ac06c6b to 8db17c7 Compare October 2, 2025 15:59
@mksh

mksh commented Oct 2, 2025 •

Copy link
Copy Markdown
Author

Saw the linter failure, so had run it locally and fixed the reported issues. Additionally, added SQLModel to the test extras in pyproject, so now test suite should run well.

@mksh

mksh commented Jan 15, 2026

Copy link
Copy Markdown
Author

Finally got back to this.

Updated code to pass tests on all platforms.

Tested in github actions of fork repo: https://github.com/mksh/sqlalchemy-continuum/actions/runs/21036613158/

@GrimHacker

Copy link
Copy Markdown

Other than the conflicts which now exist, is there anything that would prevent this merge request from being accepted @josecsotomorales ?

@marksteward

Copy link
Copy Markdown
Collaborator

Seems reasonable to me, without having gone through all the tests yet.

@GrimHacker

Copy link
Copy Markdown

I have opened #397 which extends this pull request to address the conflicts, and I hope allow it to be accepted and merged.

Please let me know if there is a more preferred approach, or any additional changes required.

Thanks

@mksh

mksh commented Jul 20, 2026

Copy link
Copy Markdown
Author

@GrimHacker Thank you for resolving the conflicts, new PR looks good to me 😄
Added some small nit pick comments there just in case

@mksh

mksh commented Aug 3, 2026

Copy link
Copy Markdown
Author

Closing in favor of #397 that contains implementation without conflicts with main, and passing latest tests (verified on my fork in https://github.com/mksh/sqlalchemy-continuum/actions/runs/29824022251/job/88613054815?pr=4)

@mksh mksh closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants