skipFetched not working for nested relation
See original GitHub issueHi there,
Thanks for the awesome library. We recently upgraded to v2.1.3 and start using the skipFetched
option to replace patterns like if (!person.children) person.$fetchGraph('children')
. It works great in most cases but I found an edge case not working.
For codes like below, assuming:
- animal => person is a many-to-one relationship
- person => country is many-to-one, too
const animal = await Animal.findById(1);
// This line will fetch as expected
await animal.$fetchGraph('owner');
// This line will throw an error like "unknown relation "country" in an eager expression"
await animal.$fetchGraph('owner.country', { skipFetched: true });
// If I change the line above to `await animal.$fetchGraph('owner.country');`, it works
Please confirm if this is an issue of skipFetched
. Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
skipFetched not working for nested relation #1757 - GitHub
It works great in most cases but I found an edge case not working. For codes like below, assuming: animal => person is...
Read more >Laravel nested relationships - Stack Overflow
I select an event by ID and i want to see which persons are subscribed to it. Now the problem is there are...
Read more >Types | Objection.js - GitHub Pages
Optional transaction or knex instance for the query. This can be used to specify a transaction or even a different database. skipFetched, boolean,...
Read more >Representing nested relations - Ideas & Features
In some apps, I have type A that is a parent to type B, which is in turn a parent to type A....
Read more >Rich Client Platform: Reference Architecture - eprints
Eclipse RCP provides solutions for frequently occurring problems. This covers ... ogical base is mentioned in relation to the goals.
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 Free
Top 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
The fix has now been released in version 2.2.1
Seconded that Objection is a wonderful library!
I’ve encountered this in my project as well when attempting to migrate
if (!model.relationType) await model.$fetchGraph('relationType')
style code.Was @broom9 's example above sufficient for purposes of finding and fixing the issue?