Skip to content

Infer timestamptz columns as TimestamptzString - #30301

Open
Sanjays2402 wants to merge 1 commit into
prisma:mainfrom
Sanjays2402:fix/infer-timestamptz-string
Open

Sanjays2402 wants to merge 1 commit into
prisma:mainfrom
Sanjays2402:fix/infer-timestamptz-string

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented Sep 15, 2026

Copy link
Copy Markdown

Fixes #30252.

contract infer mapped PostgreSQL timestamptz to the Temporal-backed Timestamptz, whose codec requires a global Temporal. Runtimes without it (e.g. Node 24) throw RUNTIME.TEMPORAL_UNAVAILABLE on the first read of an inferred contract. orm init already scaffolds TimestamptzString for the same columns, so inference and init disagreed with each other.

This maps timestamptz — including the timestamp with time zone longhand and parameterized forms like timestamptz(6) — to TimestamptzString at inference time.

Testing: regression tests cover the plain, longhand, and parameterized spellings plus a pg/timestamptz-string@1 round-trip; the tests were verified to fail before the fix. PostgreSQL PSL-inference suite (152 tests), print-PSL suite (68 tests), and affected adapter tests (142 tests) pass; biome check clean on changed files.

Summary by CodeRabbit

  • New Features

    • PostgreSQL timestamptz and timestamp with time zone columns are now inferred and rendered as TimestamptzString.
    • This behavior applies to parameterized timestamp types, such as timestamptz(6).
    • Generated schemas and defaults now consistently use the string-based timestamp representation.
  • Documentation

    • Clarified that representation-explicit string types support runtimes without Temporal, and that TimestamptzString is the default introspected spelling.

contract infer mapped timestamptz to the Temporal-backed Timestamptz,
whose codec needs a global Temporal. Runtimes without it (e.g. Node 24)
throw RUNTIME.TEMPORAL_UNAVAILABLE on the first read of an inferred
contract, and orm init already scaffolds TimestamptzString for the same
columns - so inference and init disagreed.

Map timestamptz (and its parameterized and longhand spellings) to
TimestamptzString at inference time instead.

Fixes prisma#30252.
@Sanjays2402
Sanjays2402 requested a review from a team as a code owner September 15, 2026 07:15
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Advanced

Run ID: 9277b3aa-1ab9-4918-9182-136dfca39252

📥 Commits

Reviewing files that changed from the base of the PR and between b734ad9 and 1f027fd.

📒 Files selected for processing (6)
  • packages/3-targets/3-targets/postgres/src/core/psl-infer/postgres-type-map.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/infer-parse-emit.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/postgres-type-map.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.core.test.ts
  • packages/3-targets/3-targets/postgres/test/psl-infer/print-psl/print-psl.defaults-and-types.test.ts
  • packages/3-targets/6-adapters/postgres/src/core/control-mutation-defaults.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Changes

PostgreSQL timestamptz inference

Layer / File(s) Summary
Update timestamptz type mapping
packages/3-targets/3-targets/postgres/src/core/psl-infer/postgres-type-map.ts, packages/3-targets/6-adapters/postgres/src/core/control-mutation-defaults.ts
PostgreSQL timestamptz and timestamp with time zone now map to TimestamptzString. The related comment describes the runtime representation.
Update inference and emitted PSL expectations
packages/3-targets/3-targets/postgres/test/psl-infer/*
Inference tests, codec expectations, type-map tests, and printed PSL snapshots now expect TimestamptzString and pg/timestamptz-string@1.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: wmadden-electric

Merge Risk: ⚪ Minimal · up to 1f027

The adapter normalizes precision-qualified timestamp-with-time-zone types before mapping, leaving no unresolved merge-blocking behavior in this change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: inferring PostgreSQL timestamptz columns as TimestamptzString.
Linked Issues check ✅ Passed The PR satisfies issue #30252. The PostgreSQL inference map now emits TimestamptzString for plain, longhand, and parameterized timestamptz forms. This avoids the inferred Timestamptz codec's `Te…
Out of Scope Changes check ✅ Passed The changes stay within issue #30252. Production changes update only PostgreSQL timestamptz inference and related documentation. Test changes update and extend expectations for the same mapping. No …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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.

contract infer emits Timestamptz, which fails at runtime on Node 24 with RUNTIME.TEMPORAL_UNAVAILABLE

1 participant