Error when adding a `where` to an include when included model has not entries
See original GitHub issueI have a tree that has categories.
- Each category may have child categories.
- Root level categories are those categories where
categoryId
isnull
.
When retrieving the tree, I want the first level categories eagerly loaded.
When listing trees for a given user, have to do some funky joining to get the correct trees, so I use a custom query to get the initial tree list, then loop over this list calling reload
with an includes block to populate the trees how I need them. Suboptimal? Likely but let’s please ignore that aspect for now.
I’m getting the following error when I added a where
clause to the categories
portion of my reload includes block, but only when the tree in question has no categories associated with it:
SequelizeInstanceError: Instance could not be reloaded because it does not exist anymore (find call returned null)
My tree reload code:
tree.reload(
include: [
{
model: Category,
as: 'categories',
where: {
categoryId: {
$eq: null
}
}
}
]
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Entity Framework Include() is not working - Stack Overflow
The problem might be related to the subquery in your Linq expression. Subselects, grouping und projections can cause eager loading with ...
Read more >Loading Related Entities - EF6 - Microsoft Learn
Include is an extension method in the System.Data.Entity namespace so make sure you are using that namespace. Eagerly loading multiple levels.
Read more >Looker error catalog | Google Cloud
The table below is a collection of some common error messages surfaced in Looker, explanations of their underlying causes and where they occur, ......
Read more >ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
There is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in...
Read more >Data Import error message reference - Analytics Help
Message Meaning So...
Empty column header at column number X. The upload file is missing a column header. Ed...
Multiple errors occurred: List of multiple...
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
But its probably because the reload query does not return any results at all - Which makes sequelize think that the row has been deleted. Try adding
required: false
to the incldueThanks for the response. I’ll test your suggestion @janmeier tonight.