Skip to content

Sequelize v6.12.0+ is throwing an Error when using a moment.js object in date fields #13816

@cmelendez

Description

@cmelendez

Bug Description

Sequelize is throwing an Invalid value error when using a moment.js object in DATETIME fields to do date comparisons. Additionally, when using a Moment object to set a date, the date value is set to 0000-00-00 00:00:00

This is happening since v6.12.0.

  User.findAll({
    where: {
      birthday: {
       [Op.gte]: moment()
      }
   }
  });

What do you expect to happen?

Moment objects should be accepted for date comparison, creation, etc. as usual.

What is actually happening?

An Invalid value error is thrown, crashing the app.

Invalid value Moment<2021-12-21T19:52:23+00:00>

Additional context

Environment

  • Sequelize version: 6.12.0
  • Node.js version: 16.13.0

Bug Report Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.

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

  • No, I don't have the time, although I believe I could do it if I had the time...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions