提问人:DanteC 提问时间:11/10/2023 最后编辑:LazyOneDanteC 更新时间:11/10/2023 访问量:43
Prisma 查询:参数类型。不能分配给参数类型 SelectSubSet
Prisma queries: Argument type .. is not assignable to parameter type SelectSubSet
问:
我在当前项目中使用 Next.js 和 Prisma,但在我的 IDE(目前是 WebStorm)中,我在 Prisma 中的大多数 CRUD 查询中不断收到相同的警告。
这仅在 JetBrains WebStorm 中,但是,如果我在 VSCode 中打开项目,警告就会消失......
这是警告的样子:
这是传递给 create 函数的完整内容:bookingInput
bookingInput {
start_date: '2023-11-10T15:05:52.541Z',
end_date: '2023-11-10T19:05:52.541Z',
number_of_guests: 2,
price: 240,
venue: { connect: { id: 'venue-0' } },
customer: { connect: { id: 'user-41' } }
}
这是它的类型:BookingCreateInput
export type BookingCreateInput = {
id?: string
booking_date?: Date | string
start_date: Date | string
end_date: Date | string
number_of_guests: number
host_notes?: string | null
price?: Decimal | DecimalJsLike | number | string | null
paid?: boolean
venue?: VenueCreateNestedOneWithoutBookingsInput
customer?: UserCreateNestedOneWithoutBookingsInput
}
最后,这是我的 Prisma Schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id String @id @db.VarChar(36) @default(uuid())
email String
password String
first_name String
last_name String
role USER_ROLE @default(CUSTOMER)
bookings Booking[]
ratings Rating[]
venues Venue[]
@@map("users")
}
model Venue {
id String @id @db.VarChar(36) @default(uuid())
name String @db.VarChar(50)
description String @db.MediumText
capacity Int
surface_area Decimal @db.Decimal(4, 0)
hourly_price Decimal @db.Decimal(5, 0)
opening_time DateTime @db.Time(4)
closing_time DateTime @db.Time(4)
status VENUE_STATUS @default(PENDING)
is_featured Boolean? @default(false)
location_street String
location_number String
location_city String
location_zip_code String
location_state_province String
location_country String
location_lat Decimal @default(0)
location_lng Decimal @default(0)
bookings Booking[]
ratings Rating[]
activities Activity[]
facilities Facility[]
styles Style[]
host_id String? @db.VarChar(36)
host User? @relation(fields: [host_id], references: [id], onUpdate: NoAction)
@@map("venues")
}
model Style {
id Int @id @default(autoincrement())
name String
venues Venue[]
@@map("styles")
}
model Facility {
id Int @id @default(autoincrement())
name String
venues Venue[]
@@map("facilities")
}
model Activity {
id Int @id @default(autoincrement())
name String
venues Venue[]
@@map("activities")
}
model Booking {
id String @id @db.VarChar(36) @default(uuid())
booking_date DateTime @default(now())
start_date DateTime
end_date DateTime
number_of_guests Int
host_notes String?
price Decimal? @db.Decimal(4, 0)
paid Boolean @default(false)
venue_id String? @db.VarChar(36)
customer_id String? @db.VarChar(36)
venue Venue? @relation(fields: [venue_id], references: [id], onUpdate: NoAction)
customer User? @relation(fields: [customer_id], references: [id], onUpdate: NoAction)
@@map("bookings")
}
model Rating {
id String @id @db.VarChar(36) @default(uuid())
rating Int
review String?
would_recommend Boolean
reviewer_id String? @db.VarChar(36)
venue_id String? @db.VarChar(36)
user User? @relation(fields: [reviewer_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
venue Venue? @relation(fields: [venue_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@map("ratings")
}
enum USER_ROLE {
ADMIN
CUSTOMER
HOST
}
enum VENUE_STATUS {
PENDING
APPROVED
DECLINED
}
答:
0赞
Lingxi Li
11/27/2023
#1
这似乎是 JetBrains 上 Prisma ORM 插件的问题。禁用 Prisma ORM 插件后,此警告消失。您可能应该向 JetBrains 团队报告此问题,因为他们是该插件的作者。
评论