Skip to content

Conversation

@dong-jun-shin
Copy link
Contributor

@dong-jun-shin dong-jun-shin commented Nov 27, 2025

Description

Fixes #7002

This PR adds support for BigInt values in Date hydration. This is particularly useful when using drivers like better-sqlite3 with safeIntegers: true enabled, which returns integers as BigInt.

The hydration logic generated by EntityComparator has been updated to explicitly handle typeof value === 'bigint'. It now converts the BigInt value to a Number before parsing it as a date, ensuring that timestamp values returned as BigInts are correctly hydrated into Date objects.

Dependencies

I have submitted a PR to Knex to support the option(defaultSafeIntegers: true) for the better-sqlite3 driver to return bigints (see knex/knex#5050). Testing this change will be possible once that Knex PR is resolved.

Changes

  • Updated EntityComparator to include a check for bigint type in the generated hydration code for Date properties.
  • When a bigint is encountered, it is converted to Number using Number(value) before being processed by parseDate.

Related Issue(s)

Tests

  • Added a test case to verify Date hydration.
  • Ran existing tests to ensure no regressions.

@dong-jun-shin dong-jun-shin force-pushed the fix/date-hydration-bigint branch from 118ef43 to 1784eb3 Compare November 27, 2025 04:58
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.66%. Comparing base (94927c6) to head (7db0071).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #7003    +/-   ##
========================================
  Coverage   99.66%   99.66%            
========================================
  Files         271      271            
  Lines       20483    20487     +4     
  Branches     4583     5214   +631     
========================================
+ Hits        20414    20418     +4     
  Misses         69       69            

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member

@B4nan B4nan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@B4nan B4nan merged commit 236b429 into mikro-orm:master Dec 2, 2025
12 checks passed
@dong-jun-shin dong-jun-shin deleted the fix/date-hydration-bigint branch December 2, 2025 11:20
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.

Bug: Date hydration fails when using safeIntegers (BigInt)

2 participants