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

Invalid Date when using sequelize.query #17116

Closed
3 of 6 tasks
Ankish76 opened this issue Feb 22, 2024 · 1 comment
Closed
3 of 6 tasks

Invalid Date when using sequelize.query #17116

Ankish76 opened this issue Feb 22, 2024 · 1 comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug

Comments

@Ankish76
Copy link

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

When I am using sequelize.query to get data like this
sequelize.query( 'SELECT * FROM (SELECT p.*, (st_distance_sphere(POINT(a.latitude, a.longitude), POINT($lat, $lng))/1000) AS distance FROM Pharmacies p INNER JOIN Addresses a ON a.id = p.addressId WHERE p.brandCode = $brandCode OR $brandCode IS NULL) as C WHERE distance <= $maxDistance ORDER BY distance', { bind: { lat: cords?.lat || userLat, lng: cords?.lng || userLng, maxDistance, brandCode: brandCode || null, }, // raw: true, // type: QueryTypes.SELECT, model: Pharmacy, }, )

I am getting all the date columns as Invalid date.

However

  1. When I am using models.Pharmacy.findAll() everything works as expected
  2. When downgraded mysql2 to 3.5.2 everything works as expected

What do you expect to happen?

Date column values to be a valid Date

What is actually happening?

Date column values are Invalid Date

Environment

  • Sequelize version: v6.37.1
  • Node.js version: v18.19.0
  • If TypeScript related: TypeScript version: v5.3.3
  • Database & Version: MySQL 8.0.28
  • Connector library & Version: mysql2 3.9.1

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.

@Ankish76 Ankish76 added pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug labels Feb 22, 2024
@ephys
Copy link
Member

ephys commented Mar 18, 2024

Thank you for the bug report

We are working on a fix, but I'll close this issue in favor of issue #17141, which reports the same thing

@ephys ephys closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug
Projects
None yet
Development

No branches or pull requests

2 participants