-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
docs: SQLAlchemyInitPlugin to SQLAlchemyPlugin fixes SerializationException for docs #3475
Conversation
Now uses the SQLAlchemyPlugin in stead of SQLAlchemyInitPlugin, see litestar-org#3464
Update sqlalchemy_declarative_models.py
Ruff lint fixes
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.
Thanks @JorenSix!
Beyond the missing serialization plugin, I like the idea of seeding the database with some test data!
We really should have a test for the example in tests/examples/test_contrib/test_sqlalchemy
, would you mind adding one as part of this PR? It should hit the GET /authors
endpoint and test the json response.
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
create_all flag Co-authored-by: Cody Fincher <[email protected]>
Co-authored-by: Peter Schutt <[email protected]>
Further documentation Co-authored-by: Peter Schutt <[email protected]>
Co-authored-by: Peter Schutt <[email protected]>
Co-authored-by: Cody Fincher <[email protected]>
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
I have modified the example using the suggestions above. The metadata is now created automatically, the data via on_startup. I also created a new unit test file which checks if the response is 200 and a non empty list of authors is returned. This works with recent python versions. Unfortunately this fails for older python versions (3.9, 3.10), which immediately shows why it is indeed a good idea to provide a unit test. The
Feedback or instructions on how to proceed are welcome. As an aside: I already learned a lot about the litestar CI infra and the use of the |
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
docs/examples/contrib/sqlalchemy/sqlalchemy_declarative_models.py
Outdated
Show resolved
Hide resolved
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3475 |
Thanks for following up and the quick feedback. The process and the infrastructure of litestar seems exemplary. I learned a lot about how you handle things here. Thanks again. |
@all-contributors add @JorenSix for docs |
I've put up a pull request to add @JorenSix! 🎉 |
Description
This fixes a SerializationException when running the demo with dummy data included. The example now is fixed by using the SQLAlchemyPlugin in stead of the SQLAlchemyInitPlugin and dummy data is added which immediately shows the expected behaviour: a JSON list with authors.
See issue #3464
Closes
Closes #3464