[PR #4542] [MERGED] fix: timestamp issues in kysely #5436

Closed
opened 2026-03-13 12:22:43 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4542
Author: @frectonz
Created: 9/9/2025
Status: Merged
Merged: 9/16/2025
Merged by: @himself65

Base: canaryHead: fix/timestamp-issues-in-kysely


📝 Commits (10+)

  • 47ef35a feat(kysely): add pg tests
  • 3118642 test(kysely): cross timezone timestamps
  • 893b0a5 feat(kysely): override default timestamp parser
  • b2df98d test(kysely): restore TZ after test runs
  • cf5d323 test(kysely): close postgres pool after test runs
  • cc9ed42 fix(kysely): use dynamic imports to load pg
  • 8197ef2 feat(kysely): set and reset date parser for each adapter func
  • 6fc32b1 fix(kysely): override should only run if the db is postgres
  • f43d8ce chore: cleanup
  • 8079f4f test(kysely): cross timezone timestamps in mysql

📊 Changes

7 files changed (+474 additions, -49 deletions)

View changed files

📝 packages/better-auth/src/adapters/drizzle-adapter/test/adapter.drizzle.mysql.test.ts (+30 -1)
📝 packages/better-auth/src/adapters/drizzle-adapter/test/adapter.drizzle.test.ts (+30 -1)
📝 packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts (+38 -4)
📝 packages/better-auth/src/adapters/kysely-adapter/test/normal/adapter.kysely.test.ts (+351 -40)
📝 packages/better-auth/src/adapters/test.ts (+9 -0)
📝 packages/better-auth/src/db/get-migration.ts (+3 -3)
packages/better-auth/src/utils/ensure-utc.ts (+13 -0)

📄 Description

closes #3461


Summary by cubic

Fixes timestamp parsing in the Kysely Postgres adapter by forcing UTC for TIMESTAMP values, ensuring consistent createdAt/updatedAt across timezones. Adds Postgres tests to verify cross-timezone behavior and prevent regressions.

  • Bug Fixes
    • Override pg TIMESTAMP parser to return UTC dates.
    • Add Postgres adapter tests, including cross-timezone sign up/sign in checks.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4542 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 9/9/2025 **Status:** ✅ Merged **Merged:** 9/16/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/timestamp-issues-in-kysely` --- ### 📝 Commits (10+) - [`47ef35a`](https://github.com/better-auth/better-auth/commit/47ef35a6d0dc8fc38ba342dfd16b6fea28e4ad6c) feat(kysely): add pg tests - [`3118642`](https://github.com/better-auth/better-auth/commit/31186422412f79c59d4154e2e0366a780e43fa0d) test(kysely): cross timezone timestamps - [`893b0a5`](https://github.com/better-auth/better-auth/commit/893b0a53c74643517be909a5cdc1ce707d8b2ee3) feat(kysely): override default timestamp parser - [`b2df98d`](https://github.com/better-auth/better-auth/commit/b2df98d5277b224f495186ea3659b01690fa4e19) test(kysely): restore `TZ` after test runs - [`cf5d323`](https://github.com/better-auth/better-auth/commit/cf5d3234433d9e31fa5d7b41eac2371c590b83a1) test(kysely): close postgres pool after test runs - [`cc9ed42`](https://github.com/better-auth/better-auth/commit/cc9ed428093d319d4df2107c50ebfa0a6db9dac7) fix(kysely): use dynamic imports to load `pg` - [`8197ef2`](https://github.com/better-auth/better-auth/commit/8197ef2213ace66fba138234cf7911a9dc10330a) feat(kysely): set and reset date parser for each adapter func - [`6fc32b1`](https://github.com/better-auth/better-auth/commit/6fc32b1a7b689a6e04c6e8b0b7f025818f3af2c7) fix(kysely): override should only run if the db is `postgres` - [`f43d8ce`](https://github.com/better-auth/better-auth/commit/f43d8ce0fcddc25fde87d388247e7d717ecc81fb) chore: cleanup - [`8079f4f`](https://github.com/better-auth/better-auth/commit/8079f4f57fde276731acd32d211ffd71e234d636) test(kysely): cross timezone timestamps in mysql ### 📊 Changes **7 files changed** (+474 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/drizzle-adapter/test/adapter.drizzle.mysql.test.ts` (+30 -1) 📝 `packages/better-auth/src/adapters/drizzle-adapter/test/adapter.drizzle.test.ts` (+30 -1) 📝 `packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts` (+38 -4) 📝 `packages/better-auth/src/adapters/kysely-adapter/test/normal/adapter.kysely.test.ts` (+351 -40) 📝 `packages/better-auth/src/adapters/test.ts` (+9 -0) 📝 `packages/better-auth/src/db/get-migration.ts` (+3 -3) ➕ `packages/better-auth/src/utils/ensure-utc.ts` (+13 -0) </details> ### 📄 Description closes #3461 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes timestamp parsing in the Kysely Postgres adapter by forcing UTC for TIMESTAMP values, ensuring consistent createdAt/updatedAt across timezones. Adds Postgres tests to verify cross-timezone behavior and prevent regressions. - **Bug Fixes** - Override pg TIMESTAMP parser to return UTC dates. - Add Postgres adapter tests, including cross-timezone sign up/sign in checks. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:22:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5436