Use ModelSchema.session setter rather than OPTIONS_CLASS #111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I use webargs with flask-marshmallow, there is an issue whereby webargs calls
schema.load(parsed)
, and fails because theDummySession
is returned instead of the sqlalchemy scoped session.I am relying on
init_app()
to bind the sqlalchemy session. I can see from other issues that people have suggested passingsqla_session
inMeta
, but I'd rather not copy and paste boilerplate if I can avoid it. Looking at the relevant line in marshmallow-sqlalchemy, it looks likeModelSchema.load
expectsself._session
to be set, whichModelSchema.OPTIONS_CLASS.session
doesn't do, but the setter does.The tests still pass, but as a new user of this ecosystem, I'd be happy to know if I've missed something. In particular, I know a lot of people use this stuff, so I'm not sure how it works for others.