Context is cached improperly on nested schemas
See original GitHub issueI’m running into an issue where passing parameters down into a set of schemas is breaking. I essentially have this:
class RelationshipSchema(Schema):
singular = fields.Nested(OtherSchema())
plural = fields.Nested(OtherSchema(many=True))
I have attempted to set up plural
with both a List(Nested(OtherSchema)))
structure and the current Nested(OtherSchema(many=True))
structure. Both, initially, appear to work and parse. However, within a @post_load
hook that needs to call self.context['request'].dbsession
to get a database session, the plural
fails: it will work on the first call after the services start, but then fail on subsequent calls as it somehow caches that self.context
object.
My next workaround is going to be to use threadlocals.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
c# - Entity Framework Core - Disable Model caching , call ...
Here we force the schema to all the real entities. The schema is obtained by the option attached to the context
Read more >Customizing the behavior of cached fields - Apollo GraphQL
Deriving local-only fields from one or more schema fields across multiple objects. For a full list of the options provided to the read...
Read more >Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. Subsequent jobs that use the same cache don't have to download...
Read more >Page 10 - dry-rb discussion forum
Rules for nested data not applying if parent schema has errors on other nodes ... that include input values are improperly cached when...
Read more >Performance considerations for EF 4, 5, and 6 - Microsoft Learn
Warm Query Execution; 3 Caching in the Entity Framework ... that the conceptual model might differ from the database schema in various ways....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am no longer able to reproduce this in the latest version of v2 and v3.
I believe this was fixed by https://github.com/marshmallow-code/marshmallow/pull/960, merged in 3.0.0b16.
@deckar01 @asthasr Would you guys mind double-checking and closing if it is the case?