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.

skipFetched not working for nested relation

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
koskimascommented, Jul 6, 2020

The fix has now been released in version 2.2.1

1reaction
jbkirbycommented, Jun 30, 2020

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?

Read more comments on GitHub >

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

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