Skip to content
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

Allow Fields to be subclassable #818

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Allow Fields to be subclassable #818

wants to merge 2 commits into from

Conversation

Vizonex
Copy link

@Vizonex Vizonex commented Feb 18, 2025

I bumped into a problem in my project in SQLTable which was meant to use this library to help sterilize SQLAlchemy objects to JSON with the fastest performance possible as well as the ability of having a faster init function but then I faced a problem where the Fields could not be subclassed allowing for the use of mapped-columns to be utilized, everything else that I have tried to force it to work turned up null. The SQLAlchemy Team Told me their thoughts and opinions on what my project should change in order to be better than SQLModel which I suggest looking into if this concept interests any of you.

I've tried other alternative ways such as creating a metaclass similar to this library's version but in Cython to make the code smaller but it seems that Cython is not ready for that yet so this was my backup plan of mine to make SQLAlchemy run faster.

This Idea of subclassing fields would finally let me bind mapped_column variables to msgspec fields allowing me to achieve my goals of having a faster SQL-Library than SQLModel which suffers from not being maintained all that often and with relationship values not sterilizing with the other data frustrated me.

Incase to test and make sure that my idea works I added another test to the tests folder to make sure subclassing works correctly. I do see an issue however with Field-Inspections being a problem in the future for subclassing however I don't think it's something that we should worry about at the moment and believe me when I say that I've tried everything else before pulling this final straw together.

I mainly have interests in binding my designs to aiohttp but I could see projects such as litestar start taking interest to my brand new approach.

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.

1 participant