Skip to content

throw if where receives an invalid value is a breaking change #15702

Closed

Description

@stellar-scottreed

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

Sequelize 6.28.1 will now throw an error if "undefined" is passed as a value to where. This is a backwards-incompatible breaking API change and per the semver definition should not be included in a minor version release.

This caused regressions for us all across across 10+ repos due to undefined previously being a supported value for where.

We do not explicitly pass undefined, but we have functions that accept filters as a parameter and it defaults to undefined, so if that function is called without any filters then undefined will be sent to sequelize. Yes, we could explicitly type-check for undefined before using them, but again given this is a breaking change I do not think it should have been in a minor version release. npm by default automatically upgrades you to any minor/patch versions (^ in package.json). Code that is written and works for one minor/patch version should always continue to work through any future minor/patch versions within that same major version.

Reproducible Example

const sequelize = new Sequelize('sqlite::memory:');

const User = sequelize.define('User', {
    // Model attributes are defined here
    firstName: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    lastName: {
      type: DataTypes.STRING,
    },
});

const findAllUsers = (filters) => {
    User.findAll({
        where: filters,
    });
};

findAllUsers();

What do you expect to happen?

No error would be thrown

What is actually happening?

Error is thrown: Error: Unsupported where option value: undefined. Please refer to the Sequelize documentation to learn more about which values are accepted as part of the where option.

Environment

  • Sequelize version: 6.28.1
  • Node.js version: N/A
  • Database & Version: N/A
  • Connector library & Version: N/A

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

Activity

  1. added
    pending-approval
    type: bug
    on Feb 22, 2023
  2. github-actions commented on Feb 22, 2023

    @github-actions
    Contributor

    🎉 This issue has been resolved in version 6.28.2 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-approvalreleasedtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions