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.

Error when adding a `where` to an include when included model has not entries

See original GitHub issue

I have a tree that has categories.

  • Each category may have child categories.
  • Root level categories are those categories where categoryId is null.

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

github_iconTop GitHub Comments

3reactions
janmeiercommented, Mar 14, 2016

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 incldue

1reaction
facelegcommented, Mar 14, 2016

Thanks for the response. I’ll test your suggestion @janmeier tonight.

Read more comments on GitHub >

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

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