Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d61417e
docs(psl-relation-syntax): project spec, plan, and design notes
tensordreams Jun 24, 2026
d536ca5
docs(psl-relation-syntax): slice 1 spec + dispatch plan (from/to FK f…
tensordreams Jun 24, 2026
c8924ef
feat(contract-psl): read from/to FK relation args with legacy aliasing
tensordreams Jun 24, 2026
8c1f890
docs(psl-relation-syntax): S1 spec — defer to: Model. qualifier to S5…
tensordreams Jun 24, 2026
94d82dd
feat(psl-parser): canonicalise @relation FK keywords on format
tensordreams Jun 24, 2026
343fa1c
fix(psl-parser): rename @relation key only, never a colliding bare value
tensordreams Jun 24, 2026
68d6e73
feat(contract-infer): emit canonical @relation(from:, to:) keys
tensordreams Jun 24, 2026
00fa183
feat(contract-psl)!: reject legacy @relation(fields:/references:) — f…
tensordreams Jun 30, 2026
425ddb4
refactor(examples,tests): migrate @relation(fields:/references:) to f…
tensordreams Jun 30, 2026
13fb306
test(contract-psl): assert from-to to: qualifier behaviour without me…
tensordreams Jun 30, 2026
7c62f4d
feat(mongo-family)!: from/to relation syntax; reject legacy fields/re…
tensordreams Jun 30, 2026
9903d6b
refactor(cli,fixtures,docs): migrate remaining @relation(fields:/refe…
tensordreams Jun 30, 2026
364455f
docs(psl-relation-syntax): reflect D1 reversal — clean break, reject …
tensordreams Jul 1, 2026
4bc9280
test(postgres): align psl-infer tests with post-restructure main
tensordreams Jul 8, 2026
e989680
test(supabase): expect canonical from/to keys in cross-space infer ou…
tensordreams Jul 8, 2026
dfd2de0
docs(upgrade): record from/to @relation rename for the 0.14-to-0.15 c…
tensordreams Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ model Post {
id Int @id @default(autoincrement())
title String
userId Int
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
createdAt DateTime @default(now())
}
```
Expand Down Expand Up @@ -235,7 +235,7 @@ model User {

model Profile {
id Int @id
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
userId Int @unique
}
```
Expand Down Expand Up @@ -264,7 +264,7 @@ model User {

model Post {
id Int @id
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
userId Int
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace public {
model Profile {
id String @id @default(uuid())
userId Uuid @unique
user supabase:auth.AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
user supabase:auth.AuthUser @relation(from: [userId], to: [id], onDelete: Cascade)
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ model User {
model Post {
id Int @id @default(autoincrement())
title String
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
userId Int
@@index([userId])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ namespace public {
model Profile {
id String @id @default(uuid())
userId Uuid @unique // @unique makes this a 1:1 relationship
user supabase:auth.AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
user supabase:auth.AuthUser @relation(from: [userId], to: [id], onDelete: Cascade)
@@map("profile")
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mongo-blog-leaderboard/src/contract.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ model Post {
kind String
authorId ObjectId
createdAt DateTime
author User @relation(fields: [authorId], references: [id])
author User @relation(from: [authorId], to: [id])

@@discriminator(kind)
@@index([authorId])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ model Post {
kind String
authorId ObjectId
createdAt DateTime
author User @relation(fields: [authorId], references: [id])
author User @relation(from: [authorId], to: [id])
@@discriminator(kind)
@@map("posts")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model Post {
kind String
authorId ObjectId
createdAt DateTime
author User @relation(fields: [authorId], references: [id])
author User @relation(from: [authorId], to: [id])
@@discriminator(kind)
@@map("posts")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model Post {
kind String
authorId ObjectId
createdAt DateTime
author User @relation(fields: [authorId], references: [id])
author User @relation(from: [authorId], to: [id])
@@discriminator(kind)
@@index([authorId])
@@index([createdAt(sort: Desc), authorId])
Expand Down
2 changes: 1 addition & 1 deletion examples/mongo-demo/src/contract.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model Post {
kind String
authorId ObjectId
createdAt DateTime
author User @relation(fields: [authorId], references: [id])
author User @relation(from: [authorId], to: [id])
@@discriminator(kind)
@@index([authorId])
@@index([createdAt(sort: Desc), authorId])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ model Post {
userId String
createdAt DateTime @default(now())

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])

@@map("post")
}
Expand All @@ -44,7 +44,7 @@ model Task {
userId String
createdAt DateTime @default(now())

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])

@@discriminator(type)
@@map("task")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ model Post {
createdAt DateTime @default(now())
embedding Embedding1536?

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
tags Tag[]

@@map("post")
Expand All @@ -65,8 +65,8 @@ model PostTag {
postId Uuid
tagId Uuid

post Post @relation(fields: [postId], references: [id])
tag Tag @relation(fields: [tagId], references: [id])
post Post @relation(from: [postId], to: [id])
tag Tag @relation(from: [tagId], to: [id])

@@id([postId, tagId])
@@map("post_tag")
Expand All @@ -81,7 +81,7 @@ model Task {
userId Uuid
createdAt DateTime @default(now())

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])

@@discriminator(type)
@@map("task")
Expand Down
8 changes: 4 additions & 4 deletions examples/prisma-next-demo/src/prisma/contract.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ model Post {
createdAt DateTime @default(now())
embedding Embedding1536?

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
tags Tag[]

@@map("post")
Expand All @@ -65,8 +65,8 @@ model PostTag {
postId Uuid
tagId Uuid

post Post @relation(fields: [postId], references: [id])
tag Tag @relation(fields: [tagId], references: [id])
post Post @relation(from: [postId], to: [id])
tag Tag @relation(from: [tagId], to: [id])

@@id([postId, tagId])
@@map("post_tag")
Expand All @@ -81,7 +81,7 @@ model Task {
userId Uuid
createdAt DateTime @default(now())

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])

@@discriminator(type)
@@map("task")
Expand Down
2 changes: 1 addition & 1 deletion examples/react-router-demo/src/prisma/contract.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ model Post {
userId String
createdAt DateTime @default(now())

user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])

@@map("post")
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ model Cart {
id ObjectId @id @map("_id")
userId ObjectId
items CartItem[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
@@map("carts")
@@unique([userId])
}
Expand All @@ -89,7 +89,7 @@ model Order {
shippingAddress String
type String
statusHistory StatusEntry[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
invoices Invoice[]
@@map("orders")
@@index([userId])
Expand All @@ -114,7 +114,7 @@ model Invoice {
tax Float
total Float
issuedAt DateTime
order Order @relation(fields: [orderId], references: [id])
order Order @relation(from: [orderId], to: [id])
@@map("invoices")
@@index([orderId])
@@index([issuedAt(sort: Desc)], sparse: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ model Cart {
id ObjectId @id @map("_id")
userId ObjectId
items CartItem[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
@@map("carts")
@@unique([userId])
}
Expand All @@ -90,7 +90,7 @@ model Order {
shippingAddress String
type String
statusHistory StatusEntry[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
invoices Invoice[]
@@map("orders")
@@index([userId])
Expand All @@ -115,7 +115,7 @@ model Invoice {
tax Float
total Float
issuedAt DateTime
order Order @relation(fields: [orderId], references: [id])
order Order @relation(from: [orderId], to: [id])
@@map("invoices")
@@index([orderId])
@@index([issuedAt(sort: Desc)], sparse: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ model Cart {
id ObjectId @id @map("_id")
userId ObjectId
items CartItem[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
@@map("carts")
@@unique([userId])
}
Expand All @@ -92,7 +92,7 @@ model Order {
shippingAddress String
type String
statusHistory StatusEntry[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
invoices Invoice[]
@@map("orders")
@@index([userId])
Expand All @@ -117,7 +117,7 @@ model Invoice {
tax Float
total Float
issuedAt DateTime
order Order @relation(fields: [orderId], references: [id])
order Order @relation(from: [orderId], to: [id])
@@map("invoices")
@@index([orderId])
@@index([issuedAt(sort: Desc)], sparse: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ model Cart {
id ObjectId @id @map("_id")
userId ObjectId
items CartItem[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
@@map("carts")
@@unique([userId])
}
Expand All @@ -105,7 +105,7 @@ model Order {
shippingAddress String
type OrderType
statusHistory StatusEntry[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
invoices Invoice[]
@@map("orders")
@@index([userId])
Expand All @@ -130,7 +130,7 @@ model Invoice {
tax Float
total Float
issuedAt DateTime
order Order @relation(fields: [orderId], references: [id])
order Order @relation(from: [orderId], to: [id])
@@map("invoices")
@@index([orderId])
@@index([issuedAt(sort: Desc)], sparse: true)
Expand Down
6 changes: 3 additions & 3 deletions examples/retail-store/src/contract.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ model Cart {
id ObjectId @id @map("_id")
userId ObjectId
items CartItem[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
@@map("carts")
@@unique([userId])
}
Expand All @@ -105,7 +105,7 @@ model Order {
shippingAddress String
type OrderType
statusHistory StatusEntry[]
user User @relation(fields: [userId], references: [id])
user User @relation(from: [userId], to: [id])
invoices Invoice[]
@@map("orders")
@@index([userId])
Expand All @@ -130,7 +130,7 @@ model Invoice {
tax Float
total Float
issuedAt DateTime
order Order @relation(fields: [orderId], references: [id])
order Order @relation(from: [orderId], to: [id])
@@map("invoices")
@@index([orderId])
@@index([issuedAt(sort: Desc)], sparse: true)
Expand Down
2 changes: 1 addition & 1 deletion examples/supabase/src/contract.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace public {
id Uuid @id @default(uuid())
username String
userId Uuid @unique
user supabase:auth.AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
user supabase:auth.AuthUser @relation(from: [userId], to: [id], onDelete: Cascade)
@@map("profile")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ function hasFullRelation(field: PslField): boolean {
)
.map((a) => [a.name, a.value.trim()]),
);
return named['fields'] !== undefined && named['references'] !== undefined;
// Canonical `from:`/`to:` declare the FK dependency edge; legacy
// `fields:`/`references:` are accepted as an input alias for the same edge.
const hasFrom = named['from'] !== undefined || named['fields'] !== undefined;
const hasTo = named['to'] !== undefined || named['references'] !== undefined;
return hasFrom && hasTo;
Comment on lines +272 to +276

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does this still have legacy names?

}

function relationReferencedModel(
Expand Down
Loading
Loading