Type: native contract-builder relation anchor deficiency. Target: @prisma/orm-postgres@8.0.0-rc.8.
The standalone native-only reproduction exports reproduceNativeAlternateUnique(). It needs no PostgreSQL connection and imports only Node assertions and Prisma's public contract builder.
A parent has a primary key id and a separate unique externalKey. A child declares owner: rel.belongsTo(Parent, { from: "ownerKey", to: "externalKey" }). That direction correctly emits ownerKey → externalKey. Adding child: rel.hasOne(Child, { by: "ownerKey" }) to the parent emits the inverse join as id → ownerKey, although the referenced relation targets externalKey. The reproduction asserts both emitted tuples so a native change prompts review.
For a parent whose id is record-1 and externalKey is account-1, a child's ownerKey should contain account-1. The inverse relation must therefore join the parent's externalKey, not its id. The pinned native lowerHasOwnershipRelation resolves the parent anchor from its identity; the hasOne and hasMany options provide the child by fields without a corresponding parent-field choice.
Expected behavior: the inverse metadata should join externalKey to ownerKey, matching the declared owning relation. Composite alternate unique keys should preserve the complete referenced tuple.
Public native contract metadata can represent the correct join if constructed directly with the inverse relation's on.localFields set to ["externalKey"]; that is a manual contract-level workaround. It does not correct contract-builder emission, and the generated inverse remains wrong when primary and alternate unique values differ.
Environment
@prisma/orm-postgres: 8.0.0-rc.8 (the live latest tag when reverified September 6, 2026)
- Prisma CLI:
8.0.0-rc.13
- TypeScript:
5.9.3
- Node:
26.5.0
- npm:
11.17.0
- OS: macOS 26.6.2 arm64
- PostgreSQL:
14.23 for database-backed cases
Type: native contract-builder relation anchor deficiency. Target:
@prisma/orm-postgres@8.0.0-rc.8.The standalone native-only reproduction exports
reproduceNativeAlternateUnique(). It needs no PostgreSQL connection and imports only Node assertions and Prisma's public contract builder.A parent has a primary key
idand a separate uniqueexternalKey. A child declaresowner: rel.belongsTo(Parent, { from: "ownerKey", to: "externalKey" }). That direction correctly emitsownerKey → externalKey. Addingchild: rel.hasOne(Child, { by: "ownerKey" })to the parent emits the inverse join asid → ownerKey, although the referenced relation targetsexternalKey. The reproduction asserts both emitted tuples so a native change prompts review.For a parent whose
idisrecord-1andexternalKeyisaccount-1, a child'sownerKeyshould containaccount-1. The inverse relation must therefore join the parent'sexternalKey, not itsid. The pinned nativelowerHasOwnershipRelationresolves the parent anchor from its identity; thehasOneandhasManyoptions provide the childbyfields without a corresponding parent-field choice.Expected behavior: the inverse metadata should join
externalKeytoownerKey, matching the declared owning relation. Composite alternate unique keys should preserve the complete referenced tuple.Public native contract metadata can represent the correct join if constructed directly with the inverse relation's
on.localFieldsset to["externalKey"]; that is a manual contract-level workaround. It does not correct contract-builder emission, and the generated inverse remains wrong when primary and alternate unique values differ.Environment
@prisma/orm-postgres:8.0.0-rc.8(the livelatesttag when reverified September 6, 2026)8.0.0-rc.135.9.326.5.011.17.014.23for database-backed cases