-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: Add Sqlalchemy factory #342
feat: Add Sqlalchemy factory #342
Conversation
388e3de
to
74f99fe
Compare
@cofin @provinzkraut and @guacs - i assigned you to this PR since I would like people with more substantial SQLA experience than myself to make the decisions here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same doubts as mentioned in this comment in #278. How does this handle things like relationships and such?
Also, I think it might be nice to have more tests that covers all the types as in these tests for pydantic. At least for the types that have been kept in the get_ssqlalchemy_types
.
types_override = cls.get_sqlalchemy_types() | ||
columns = cls.__model__.__table__.columns | ||
for name, column in columns.items(): | ||
annotation: type = type(column.type) if type(column.type) in types_override else column.type.python_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the handling of the type of the items in the list if the type is ARRAY
is missing. If I'm not mistaken, column.type.python_type
will only return list
and not List[str]
or List[int]
or whatever be the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I have updated to extract origin for ARRAY SQLAlchemy type here.
Note I think a similar issue exists for tuple type but I wasn't able to add better support for this easily.
I have updated to support relationships optionally by class level configuration with default not parsing these. Default here was chosen to prevent recursion errors. In regards to association properties and hybrid properties, I do not think need to explicitly set these as will implicitly set by just setting the columns. Happy to add a test to confirm these are ignored. |
4577eb4
to
e9b9cae
Compare
@adhtruong I rebased the base branch and updated it. Please rebase your PR. |
cd52ed3
to
c67843f
Compare
@all-contributors add @adhtruong code |
I've put up a pull request to add @adhtruong! 🎉 |
* feat: Add SQLAlchemyFactory table column parsing * docs: Add SQLAlchemy reference * docs: amend link * doc: amend link * Revert type updates * feat: add SQLAlchemy relationship configuration * feat: improve mapping for SQLAlchemy ARRAY * feat: SQLAlchemy test hints for 3.8 * feat: SQLAlchemy test hints for 3.8 * feat: SQLAlchemy test hints for 3.8 * feat: SQLAlchemy factory hints for 3.8 * feat: add extra attributes for SQLAlchemyFactory * feat: resolve SQLAlchemyFactory type issues * feat: fix rebase errors
* feat: add sqlalchemy factory (initial) * feat: Add Sqlalchemy factory (#342) * feat: Add SQLAlchemyFactory table column parsing * docs: Add SQLAlchemy reference * docs: amend link * doc: amend link * Revert type updates * feat: add SQLAlchemy relationship configuration * feat: improve mapping for SQLAlchemy ARRAY * feat: SQLAlchemy test hints for 3.8 * feat: SQLAlchemy test hints for 3.8 * feat: SQLAlchemy test hints for 3.8 * feat: SQLAlchemy factory hints for 3.8 * feat: add extra attributes for SQLAlchemyFactory * feat: resolve SQLAlchemyFactory type issues * feat: fix rebase errors * feat: Add SQLA persistence handles, update class attributes * docs: Add SQLAFactory docs * test: add missing __init__ files, fix imports, fix rebase errors * docs: fix SQLA class ref --------- Co-authored-by: Na'aman Hirschfeld <nhirschfeld@gmail.com>
Pull Request Checklist
Description
Close Issue(s)