-
-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Support mixins #256
base: main
Are you sure you want to change the base?
🐛 Support mixins #256
Conversation
I thought I was already using mixins, when say this in our fastapi-users integration (using https://github.com/fastapi-users/fastapi-users-db-sqlmodel)
But am guessing that works because both those classes inherit SQLModel. Just double checking: is it a good idea to add this to support mixins that are not SQLModel's? I guess yes. |
Would it be possible for you to test this with your project, @antont? It would be reassuring if your tests pass as well. |
Yes, I can do that either later today or else at some point tomorrow. |
Is there hope for a merge at all? I see a long list of useful PRs that haven't been merged and are outdated by now. |
I just merge the PRs we need in our company fork (public). I guess others do the same. But yes there is hope, tiangolo seems to merge too and release when he has time, is just busy working on these on other fronts too, fastapi, pydantic etc. SQLModel is quite small and was pretty solid when it was first released, I'd bet most of the PRs are not outdated as not much has changed. |
@byrman - works for me, so didn't break mixins that derive from SQLModel. makes sense too, didn't suspect problems either and the change seems logical too. |
Thanks for testing in the wild, @antont! |
Hope to see this merged soon 🙏 |
Until this is merged, here's an easy workaround:
|
Unfortunately, this use case is not covered: #330. Only methods and simple attributes appear to work. |
Thanks for testing these solutions. @bolau I just tried your suggested approach and am having an issue where the introduction of
|
Codecov Report
@@ Coverage Diff @@
## main #256 +/- ##
=======================================
Coverage 97.76% 97.77%
=======================================
Files 187 188 +1
Lines 6268 6280 +12
=======================================
+ Hits 6128 6140 +12
Misses 140 140
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
📝 Docs preview for commit 3c68587 at: https://630f80b819e9472c1e2ab9ba--sqlmodel.netlify.app |
Sorry, no. Maybe it's not a good workaround after all ;-) Hope that this gets merged sometime soon... |
#256 fixes Mixin usage with https://github.com/absent1706/sqlalchemy-mixins ;) |
📝 Docs preview for commit 6f0c4bb at: https://639ce01f2b35ad0062e48357--sqlmodel.netlify.app |
Well... up ! |
@byrman will relationship fields in mixins work with this? |
This worked well for me. I don't see official support for mixins in the documentation yet. |
@tiangolo Sorry to bother, but any reason this actually doesn't get pulled ? |
The
|
Add support for mixins to be used with
SQLModel
. See #254.