fix(adapter-pg,adapter-neon,adapter-ppg): support TIMETZ[] columns - #30148
fix(adapter-pg,adapter-neon,adapter-ppg): support TIMETZ[] columns#30148UgaTheDev wants to merge 1 commit into
Conversation
Selecting a `timetz[]` column threw `UnsupportedNativeDataType` (surfaced as P2010) because OID 1270 was missing from ArrayColumnType, had no case in fieldToColumnType, and had no registered array parser, so it fell through to the default branch. Map OID 1270 to ColumnTypeEnum.TimeArray and register the array parser using the same element normalizer as scalar TIMETZ, so array and scalar TIMETZ stay byte-for-byte consistent. This does not change the offset semantics tracked in prisma#7915/prisma#7917. Fixes prisma#29397 Signed-off-by: Kush Zingade <kush.zingade@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Neon, PostgreSQL, and PPG adapters now support PostgreSQL ChangesTIMETZ array adapter support
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR enables TIMETZ[] deserialization across the three adapters while preserving existing scalar timetz normalization; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The PR addresses the adapter conversion gap for PostgreSQL TIMETZ[] deserialization by adding OID 1270 mappings and parsers in all three adapters. The tests cover the required type mapping and normalization behavior for issue
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Fixes #29397
Base branch:
v7(the Prisma 8maintree no longer contains theadapter-*packages).Problem
Any query touching a
timetz[]column fails with a deserialization error surfaced asP2010:Root cause (posted on #29397): in
packages/adapter-pg/src/conversion.ts, theArrayColumnTypemap has no entry for
TIMETZ_ARRAY(OID 1270),fieldToColumnTypetherefore has no case for it,and no parser is registered for it. The OID is below
FIRST_NORMAL_OBJECT_ID, so it is not treatedas a user type either and falls straight through to
default:, which throwsUnsupportedNativeDataType. Scalartimetz(OID 1266) is handled; only the array form is missing.adapter-neonandadapter-ppgcarry copies of the same conversion table and have the identicalgap, so all three are fixed here.
Change
For each of the three adapters:
TIMETZ_ARRAY: 1270added toArrayColumnType.fieldToColumnTypemaps it toColumnTypeEnum.TimeArray, alongsideTIME_ARRAY— matching howscalar
TIMETZalready sharesColumnTypeEnum.TimewithTIME.normalize_array(normalize_timez), i.e. the elementnormalizer is the existing scalar
TIMETZnormalizer, used as-is.Scope: array mapping only
This PR is deliberately "stop throwing" and nothing more.
normalize_timezstrips the UTC offset from the value, which is the behavior discussed in #7915 /#7917. That behavior is intentionally reused unchanged here, so
timetz[]elements deserializebyte-for-byte identically to a scalar
timetzcolumn on the same connection. Whatever themaintainers decide about
timetzoffset semantics will then apply to scalars and arrays together,with no separate array code path to remember. This PR does not preempt that decision.
Tests
packages/adapter-pg/src/__tests__/timetz-array.test.ts(new)packages/adapter-neon/src/__tests__/timetz-array.test.ts(new)packages/adapter-ppg/src/conversion.test.ts(newdescribe('TIMETZ[]')block, following thefile's existing
getParser(oid)pattern)Each asserts that OID 1270 maps to
TimeArrayand that the registered parser normalizes elementsexactly like the scalar path (
'{10:30:00+02,11:00:00-05:00,12:00:00}'→['10:30:00', '11:00:00', '12:00:00']).Verified failing on
v7before the fix withUnsupportedNativeDataType, passing after. Full unitsuites for all three adapter packages are green (
adapter-pg57,adapter-neon10,adapter-ppg43 tests).
Not covered: an end-to-end
driver-adaptersintegration test against a realtimetz[]column,since that would need a schema fixture in the functional test suite. Happy to add one if you'd
prefer the coverage there instead of / in addition to the unit level.
Summary by CodeRabbit
New Features
TIMETZ[]columns across Neon, PostgreSQL, and PPG adapters.TIMETZ[]values are now recognized as time arrays and normalized consistently with scalarTIMETZvalues.Tests
TIMETZ[]values.