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

🔥 Remove old/unused parameter sqlalchemy_safe from jsonable_encoder #1864

Merged
merged 1 commit into from
Aug 9, 2020

Conversation

tiangolo
Copy link
Member

@tiangolo tiangolo commented Aug 9, 2020

🔥 Remove old/unused parameter sqlalchemy_safe from jsonable_encoder.

It was an early hack to allow returning SQLAlchemy models, but it was never documented, and the recommended way is using Pydantic's orm_mode as described in: https://fastapi.tiangolo.com/tutorial/sql-databases/

@codecov
Copy link

codecov bot commented Aug 9, 2020

Codecov Report

Merging #1864 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1864   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          239       239           
  Lines         7079      7079           
=========================================
  Hits          7079      7079           
Impacted Files Coverage Δ
fastapi/encoders.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64ca596...82e24ff. Read the comment docs.

@github-actions github-actions bot temporarily deployed to commit August 9, 2020 20:30 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2020

@tiangolo tiangolo merged commit cdba848 into master Aug 9, 2020
@tiangolo tiangolo deleted the jsonable_encoder_remove_sqlalchemy_safe branch August 9, 2020 20:33
@shawnwall
Copy link

I can't quite figure out if this was the commit that did it, but if you try to do the following now you get a stack overflow:

obj_data = jsonable_encoder(some_sqla_model_instance)

This breaks the update pattern found in https://github.com/tiangolo/full-stack-fastapi-postgresql/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/backend/app/app/crud/base.py

@mvilanova
Copy link

All our Pydantic models inherit from the same base model which has orm_mode = True and we're also getting a stack overflow.

@tiangolo
Copy link
Member Author

Thanks for pointing this out @shawnwall and @mvilanova ! 🔍 🐛

I reverted it in #1987 , available in FastAPI version 0.61.1 (released today in a couple of hours).

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.

3 participants