Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error: NotFound: No record found for id" when calling with socket.io #179

Closed
jaslocum opened this issue Nov 9, 2017 · 6 comments
Closed

Comments

@jaslocum
Copy link

jaslocum commented Nov 9, 2017

This code change avoids the above error in my app:

9ece87e

@daffl
Copy link
Member

daffl commented Nov 9, 2017

Maybe @MichaelErmer has some more insights into this.

@MichaelErmer
Copy link
Contributor

MichaelErmer commented Nov 10, 2017

Can you explain this a bit more? I don't see how this could cause the error, as !== already does a type sensitive check.
What is the error you get?

Your change is bad as it changes the default behaviour, if params.$returning is not set, to handle it as true, but params.$returning should be optional.

The error just tells you that you are trying to edit/delete a object that does not exist, the error is correct.

@DesignByOnyx
Copy link
Contributor

DesignByOnyx commented Nov 22, 2017

I agree that the change you've suggested is not correct - while it may cause the error to go away in your app, it's not fixing the problem.

The real problem is to figure out why records are not found when this code runs:

return _this2._getOrFind(id, findParams);

@jaslocum Can you please investigate since you are able to produce the error. Remove the code you added and try to see what the value of "id" and "findParams" are. I recommend turning on logging on the sequelize adapter so you can inspect the queries:

new Sequelize(connectionString, {
    dialect: 'postgres',
    logging: console.log,
    define: {
      freezeTableName: true
    }
  });

@jpapini
Copy link

jpapini commented Jan 14, 2018

The problem is due to the $in query parameters in the patch function.

Solved this error by setting up operatorsAliases in the sequelize configuration as explained here http://docs.sequelizejs.com/manual/tutorial/querying.html#operators-security:

const Op = Sequelize.Op;
const operatorsAliases = {
    $eq: Op.eq,
    $ne: Op.ne,
    $gte: Op.gte,
    $gt: Op.gt,
    $lte: Op.lte,
    $lt: Op.lt,
    $not: Op.not,
    $in: Op.in,
    $notIn: Op.notIn,
    $is: Op.is,
    $like: Op.like,
    $notLike: Op.notLike,
    $iLike: Op.iLike,
    $notILike: Op.notILike,
    $regexp: Op.regexp,
    $notRegexp: Op.notRegexp,
    $iRegexp: Op.iRegexp,
    $notIRegexp: Op.notIRegexp,
    $between: Op.between,
    $notBetween: Op.notBetween,
    $overlap: Op.overlap,
    $contains: Op.contains,
    $contained: Op.contained,
    $adjacent: Op.adjacent,
    $strictLeft: Op.strictLeft,
    $strictRight: Op.strictRight,
    $noExtendRight: Op.noExtendRight,
    $noExtendLeft: Op.noExtendLeft,
    $and: Op.and,
    $or: Op.or,
    $any: Op.any,
    $all: Op.all,
    $values: Op.values,
    $col: Op.col
};

const sequelize = new Sequelize(connectionString, {
    dialect: 'sqlite',
    logging: false,
    define: {
        freezeTableName: true
    },
    operatorsAliases: operatorsAliases
});

@daffl
Copy link
Member

daffl commented Jan 14, 2018

@MichaelErmer
Copy link
Contributor

MichaelErmer commented Jan 23, 2018

No, #179 (comment) is a different issue, this issue should be closed as its a user error.

@daffl daffl closed this as completed Jan 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants