Skip to content

fix: zero dates come back as "undefined 00:00:00" with dateStrings - #4491

Merged
sidorares merged 1 commit into
sidorares:masterfrom
NotAFlightRisk:fix/binary-zero-date-datestrings
Aug 23, 2026
Merged

fix: zero dates come back as "undefined 00:00:00" with dateStrings#4491
sidorares merged 1 commit into
sidorares:masterfrom
NotAFlightRisk:fix/binary-zero-date-datestrings

Conversation

@NotAFlightRisk

Copy link
Copy Markdown
Contributor

With dateStrings on, a zero DATETIME or TIMESTAMP read through execute() comes back as the string undefined 00:00:00, and a zero DATE as plain undefined. query() gives 0000-00-00 00:00:00 and 0000-00-00 for the same rows. Thats MySQL 9.7.2 here, I've not tried MariaDB. A typeCast function calling field.string() lands on it too, without dateStrings involved at all.

When every part of the value is zero the server sends a zero-length payload, so str never gets assigned and the midnight branch appends to undefined. test-datestrings-binary-zero-time.test.mts covers the neighbouring case but uses a real date at midnight, so it never reaches that path.

The !str check in readDateTime was only there to swalow the undefined (#4258), so it's looking for the zero date itself now. Read as Dates they're still Invalid Date and test-#1019.test.mts passes either way.

@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.09%. Comparing base (928c3c5) to head (87a6ede).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4491   +/-   ##
=======================================
  Coverage   92.09%   92.09%           
=======================================
  Files          92       92           
  Lines       15213    15214    +1     
  Branches     2086     2086           
=======================================
+ Hits        14011    14012    +1     
  Misses       1202     1202           
Flag Coverage Δ
compression-0 91.65% <100.00%> (+<0.01%) ⬆️
compression-1 92.07% <100.00%> (+<0.01%) ⬆️
static-parser-0 90.86% <100.00%> (+<0.01%) ⬆️
static-parser-1 91.12% <100.00%> (+<0.01%) ⬆️
tls-0 91.64% <100.00%> (+<0.01%) ⬆️
tls-1 92.09% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sidorares
sidorares merged commit 5bf7bda into sidorares:master Aug 23, 2026
104 checks passed
sidorares added a commit that referenced this pull request Aug 23, 2026
Conflicts: lib/packets/packet.js
- kept master's ZERO_DATE prefix detection for binary zero dates
  (#4491) but return a fresh new Date(NaN) instead of the shared
  INVALID_DATE singleton, which this branch removed (Date is mutable)
- dropped the now-unused INVALID_DATE constant
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

Successfully merging this pull request may close these issues.

2 participants