question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Context is cached improperly on nested schemas

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
deckar01commented, Dec 4, 2018

I am no longer able to reproduce this in the latest version of v2 and v3.

0reactions
lafrechcommented, Dec 4, 2018

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found