Skip to content

Commit 6b7284a

Browse files
borisno2claude
andauthored
Fix virtual fields typed as never when mixed with relation fields in select/include (#384)
* Fix virtual fields typed as \`never\` when mixed with relation fields in select/include Adds a \`StripVirtualFromArgs\` utility type to the generated \`.opensaas/types.ts\` that strips virtual field keys from the select/include object before passing it to \`Prisma.*GetPayload<>\`. This prevents Prisma from trying to resolve virtual field names (which don't exist in its schema), which previously produced \`never\` that poisoned the intersection with the virtual fields type. Closes #383 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * regenerate schema * Update prisma.test.ts.snap --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9e4d730 commit 6b7284a

File tree

15 files changed

+773
-32
lines changed

15 files changed

+773
-32
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@opensaas/stack-cli': patch
3+
---
4+
5+
Fix virtual fields typed as `never` when mixed with relation fields in `select` or when using `include`

examples/auth-demo/prisma/schema.prisma

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ model Post {
1818
authorId String? @map("author")
1919
author User? @relation(fields: [authorId], references: [id])
2020
createdAt DateTime @default(now())
21-
updatedAt DateTime @updatedAt
21+
updatedAt DateTime @default(now()) @updatedAt
2222
2323
@@index([authorId])
2424
}
@@ -33,7 +33,7 @@ model User {
3333
accounts Account[]
3434
posts Post[]
3535
createdAt DateTime @default(now())
36-
updatedAt DateTime @updatedAt
36+
updatedAt DateTime @default(now()) @updatedAt
3737
}
3838

3939
model Session {
@@ -45,7 +45,7 @@ model Session {
4545
userId String? @map("user")
4646
user User? @relation(fields: [userId], references: [id])
4747
createdAt DateTime @default(now())
48-
updatedAt DateTime @updatedAt
48+
updatedAt DateTime @default(now()) @updatedAt
4949
5050
@@index([userId])
5151
}
@@ -64,7 +64,7 @@ model Account {
6464
userId String? @map("user")
6565
user User? @relation(fields: [userId], references: [id])
6666
createdAt DateTime @default(now())
67-
updatedAt DateTime @updatedAt
67+
updatedAt DateTime @default(now()) @updatedAt
6868
6969
@@index([userId])
7070
}
@@ -75,5 +75,5 @@ model Verification {
7575
value String
7676
expiresAt DateTime?
7777
createdAt DateTime @default(now())
78-
updatedAt DateTime @updatedAt
78+
updatedAt DateTime @default(now()) @updatedAt
7979
}

examples/blog/prisma/schema.prisma

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ model Settings {
1313
maintenanceMode Boolean @default(false)
1414
maxUploadSize Int?
1515
createdAt DateTime @default(now())
16-
updatedAt DateTime @updatedAt
16+
updatedAt DateTime @default(now()) @updatedAt
1717
}
1818

1919
model User {
@@ -23,7 +23,7 @@ model User {
2323
password String
2424
posts Post[]
2525
createdAt DateTime @default(now())
26-
updatedAt DateTime @updatedAt
26+
updatedAt DateTime @default(now()) @updatedAt
2727
}
2828

2929
model Post {
@@ -38,7 +38,7 @@ model Post {
3838
authorId String? @map("author")
3939
author User? @relation(fields: [authorId], references: [id])
4040
createdAt DateTime @default(now())
41-
updatedAt DateTime @updatedAt
41+
updatedAt DateTime @default(now()) @updatedAt
4242
4343
@@index([authorId])
4444
}

examples/composable-dashboard/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ model User {
1414
password String
1515
posts Post[]
1616
createdAt DateTime @default(now())
17-
updatedAt DateTime @updatedAt
17+
updatedAt DateTime @default(now()) @updatedAt
1818
}
1919

2020
model Post {
@@ -28,7 +28,7 @@ model Post {
2828
authorId String? @map("author")
2929
author User? @relation(fields: [authorId], references: [id])
3030
createdAt DateTime @default(now())
31-
updatedAt DateTime @updatedAt
31+
updatedAt DateTime @default(now()) @updatedAt
3232
3333
@@index([authorId])
3434
}

examples/custom-field/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ model User {
1515
favoriteColor String?
1616
posts Post[]
1717
createdAt DateTime @default(now())
18-
updatedAt DateTime @updatedAt
18+
updatedAt DateTime @default(now()) @updatedAt
1919
}
2020

2121
model Post {
@@ -29,7 +29,7 @@ model Post {
2929
authorId String? @map("author")
3030
author User? @relation(fields: [authorId], references: [id])
3131
createdAt DateTime @default(now())
32-
updatedAt DateTime @updatedAt
32+
updatedAt DateTime @default(now()) @updatedAt
3333
3434
@@index([authorId])
3535
}

examples/file-upload-demo/prisma/schema.prisma

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ model User {
1414
avatar Json?
1515
posts Post[]
1616
createdAt DateTime @default(now())
17-
updatedAt DateTime @updatedAt
17+
updatedAt DateTime @default(now()) @updatedAt
1818
}
1919

2020
model Post {
@@ -26,5 +26,7 @@ model Post {
2626
authorId String? @map("author")
2727
author User? @relation(fields: [authorId], references: [id])
2828
createdAt DateTime @default(now())
29-
updatedAt DateTime @updatedAt
29+
updatedAt DateTime @default(now()) @updatedAt
30+
31+
@@index([authorId])
3032
}

examples/json-demo/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ model Product {
1414
settings Json?
1515
configuration Json
1616
createdAt DateTime @default(now())
17-
updatedAt DateTime @updatedAt
17+
updatedAt DateTime @default(now()) @updatedAt
1818
}
1919

2020
model Article {
@@ -23,5 +23,5 @@ model Article {
2323
content Json?
2424
taxonomy Json?
2525
createdAt DateTime @default(now())
26-
updatedAt DateTime @updatedAt
26+
updatedAt DateTime @default(now()) @updatedAt
2727
}

examples/rag-openai-chatbot/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ model KnowledgeBase {
1515
published Boolean @default(true)
1616
contentEmbedding Json?
1717
createdAt DateTime @default(now())
18-
updatedAt DateTime @updatedAt
18+
updatedAt DateTime @default(now()) @updatedAt
1919
}

examples/starter-auth/prisma/schema.prisma

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ model Post {
1818
authorId String? @map("author")
1919
author User? @relation(fields: [authorId], references: [id])
2020
createdAt DateTime @default(now())
21-
updatedAt DateTime @updatedAt
21+
updatedAt DateTime @default(now()) @updatedAt
2222
2323
@@index([authorId])
2424
}
@@ -33,7 +33,7 @@ model User {
3333
accounts Account[]
3434
posts Post[]
3535
createdAt DateTime @default(now())
36-
updatedAt DateTime @updatedAt
36+
updatedAt DateTime @default(now()) @updatedAt
3737
}
3838

3939
model Session {
@@ -45,7 +45,7 @@ model Session {
4545
userId String? @map("user")
4646
user User? @relation(fields: [userId], references: [id])
4747
createdAt DateTime @default(now())
48-
updatedAt DateTime @updatedAt
48+
updatedAt DateTime @default(now()) @updatedAt
4949
5050
@@index([userId])
5151
}
@@ -64,7 +64,7 @@ model Account {
6464
userId String? @map("user")
6565
user User? @relation(fields: [userId], references: [id])
6666
createdAt DateTime @default(now())
67-
updatedAt DateTime @updatedAt
67+
updatedAt DateTime @default(now()) @updatedAt
6868
6969
@@index([userId])
7070
}
@@ -75,5 +75,5 @@ model Verification {
7575
value String
7676
expiresAt DateTime?
7777
createdAt DateTime @default(now())
78-
updatedAt DateTime @updatedAt
78+
updatedAt DateTime @default(now()) @updatedAt
7979
}

examples/starter/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ model User {
1414
password String
1515
posts Post[]
1616
createdAt DateTime @default(now())
17-
updatedAt DateTime @updatedAt
17+
updatedAt DateTime @default(now()) @updatedAt
1818
}
1919

2020
model Post {
@@ -28,7 +28,7 @@ model Post {
2828
authorId String? @map("author")
2929
author User? @relation(fields: [authorId], references: [id])
3030
createdAt DateTime @default(now())
31-
updatedAt DateTime @updatedAt
31+
updatedAt DateTime @default(now()) @updatedAt
3232
3333
@@index([authorId])
3434
}

0 commit comments

Comments
 (0)