feat: add Temporal support to escape#42
Merged
Merged
Conversation
Escaping a Temporal value (e.g. Temporal.Instant) currently falls through to the generic object handling and produces broken SQL. Teach escape() about Temporal, mirroring the existing Date handling. - Instant / ZonedDateTime: absolute times, delegated to dateToString so the timezone argument behaves exactly as it does for Date (millisecond precision). - PlainDateTime / PlainDate / PlainTime: wall-clock values, emitted verbatim as DATETIME / DATE / TIME literals (timezone ignored). - Other Temporal types fall back to their ISO string. Temporal types are detected via Object.prototype.toString (Symbol.toStringTag), so the Temporal global is never referenced and no Temporal lib types are needed; the new TemporalLike type is declared structurally. Adds tests (skipped when Temporal is unavailable) and README docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pdeveltere
force-pushed
the
feat/temporal-escape
branch
from
July 11, 2026 11:30
7af099a to
720fd26
Compare
This was referenced Jul 11, 2026
pdeveltere
commented
Jul 11, 2026
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 548 561 +13
=========================================
+ Hits 548 561 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wellwelwel
requested changes
Jul 12, 2026
wellwelwel
left a comment
Member
There was a problem hiding this comment.
Thanks, @pdeveltere! I've noted a few points to review. Feel free to reach out if you need any help 🙋🏻♂️
- type Temporal values via the esnext.temporal lib (unblocked by mysqljs#44) instead of the structural TemporalLike shape - add tests for the ISO-string fallback (Duration, PlainYearMonth, PlainMonthDay) - run Temporal tests on every runtime via @js-temporal/polyfill (dev-only) so coverage no longer depends on the CI Node version - trim comments to decision notes per review
Contributor
Author
|
@wellwelwel thanks for the quick review! I think I've attended all the points, let me know if something is missing still. |
wellwelwel
approved these changes
Jul 12, 2026
wellwelwel
left a comment
Member
There was a problem hiding this comment.
Thanks again, @pdeveltere!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Escaping a Temporal value (e.g.
Temporal.Instant) currently falls through to the generic object handling and produces broken SQL. This teachesescape()about Temporal, mirroring the existingDatehandling.Behavior
Instant/ZonedDateTime: absolute times, delegated todateToStringso thetimezoneargument behaves exactly as it does forDate(millisecond precision).PlainDateTime/PlainDate/PlainTime: wall-clock values, emitted verbatim asDATETIME/DATE/TIMEliterals (timezoneignored).Duration,PlainYearMonth,PlainMonthDay) fall back to their ISO string.Notes
esnext.temporallib: the newTemporalValueunion (part ofSqlValue) covers all eight Temporal types.Symbol.toStringTag-based (Object.prototype.toString), so theTemporalglobal is never referenced and polyfilled values work too.Temporalglobal when present and fall back to@js-temporal/polyfill(dev-only dependency) otherwise — CI'slts/*Node has no Temporal global yet, so without the fallback the suite would silently skip (this is what previously showed up as low patch coverage).