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.

DataLoader issue with $in

See original GitHub issue

When I use the following from the example

  const users = await models.User.findAll({
    where: {
      id: {
        $in: keys,
      },
    },
  });

I get the following error

{
  "errors": [
    {
      "message": "Invalid value { '$in': [ 1, 2, 3 ] }",
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ],
      "path": [
        "accounts",
        0,
        "user"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: Invalid value { '$in': [ 1, 2, 3 ] }",
            "    at Object.escape (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/sql-string.js:66:11)",
            "    at Object.escape (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:936:22)",
            "    at Object._whereParseSingleValueObject (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2432:41)",
            "    at Object.whereItemQuery (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2136:21)",
            "    at Utils.getComplexKeys.forEach.prop (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1997:25)",
            "    at Array.forEach (<anonymous>)",
            "    at Object.whereItemsQuery (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1995:35)",
            "    at Object.getWhereConditions (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2459:19)",
            "    at Object.selectQuery (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1143:28)",
            "    at QueryInterface.select (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/query-interface.js:1105:27)",
            "    at Promise.try.then.then.then (/Users/***/Documents/code/*** /***-server/node_modules/sequelize/lib/model.js:1598:34)",
            "    at tryCatcher (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/util.js:16:23)",
            "    at Promise._settlePromiseFromHandler (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/promise.js:512:31)",
            "    at Promise._settlePromise (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/promise.js:569:18)",
            "    at Promise._settlePromise0 (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/promise.js:614:10)",
            "    at Promise._settlePromises (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/promise.js:694:18)",
            "    at _drainQueueStep (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/async.js:138:12)",
            "    at _drainQueue (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/async.js:131:9)",
            "    at Async._drainQueues (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/async.js:147:5)",
            "    at Immediate.Async.drainQueues [as _onImmediate] (/Users/***/Documents/code/*** /***-server/node_modules/bluebird/js/release/async.js:17:14)",
            "    at processImmediate (timers.js:632:19)"
          ]
        }
      }
    }
  ],
  "data": {
    "accounts": null
  }
}

if I change it to the following then everything works

  const users = await models.User.findAll({
    where: {
      id: keys,
    },
  });

I don’t know if this is because I have a newer package or something. But it took me hours to figure it out, so I figured I would share with everyone else

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
rwieruchcommented, Feb 11, 2019

Thanks for confirming this @crashspringfield I will take this issue into for the next book edition.

In case someone else runs into this issue, please write a comment here and how you worked around the issue 😃

1reaction
fmtmecommented, Jan 12, 2020

https://sequelize.org/master/manual/querying.html#where

imported Op module from sequelize and replaced $in with [Op.in]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common error messages in Data Loader - Salesforce Help
Common error messages in Data Loader · Error: Row is larger than header · Error: Insufficient access rights to object ID / insufficient...
Read more >
Troubleshooting - Dataloader.io
Here we list some common issues and their fixes. Hopefully you won't run into any of them, but if you do we've got...
Read more >
Having trouble logging in to dataloader.io
Having trouble logging in to dataloader.io · Your Salesforce Org has blocked dataloader.io · Your Salesforce Org has reached the API Calls Limit....
Read more >
10 Common Errors with Salesforce Data loading explained
When loading data into Salesforce, it is extremely common to have errors occur. Here is a list of 10 of the most common...
Read more >
dataloader.io Support Process - MuleSoft Help Center
In case you are still facing login issues, please, contact us by email at info@dataloader.io. ... In that case, please, use the dataloader.io...
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