b0ngl0rd
b0ngl0rd
PPrisma
Created by b0ngl0rd on 10/17/2024 in #help-and-questions
Argument `where` of type *WhereUniqueInput needs at least one of `id` arguments.
No TS or linting warnings, and yet I am running into a problem with a simple update query. Relevant query:
ctx.db.table.update({
where: {
id: table.id,
},
data: {
relief: {
disconnect: true,
},
dealer: {
connect: table.relief ? { id: table.relief.id } : undefined,
},
dealerStartTime: new Date(),
},
}),
ctx.db.table.update({
where: {
id: table.id,
},
data: {
relief: {
disconnect: true,
},
dealer: {
connect: table.relief ? { id: table.relief.id } : undefined,
},
dealerStartTime: new Date(),
},
}),
Log of input provided to query before calling it:
[ { id: 57, relief: { id: 201 }, dealer: null } ]
[ { id: 57, relief: { id: 201 }, dealer: null } ]
Log of error:
PrismaClientValidationError:
Invalid `prisma.table.update()` invocation:

{
where: {
id: 57,
? AND?: DealerWhereInput | DealerWhereInput[],
? OR?: DealerWhereInput[],
? NOT?: DealerWhereInput | DealerWhereInput[],
? name?: StringFilter | String,
? startTime?: DateTimeFilter | DateTime,
? breakStartTime?: DateTimeNullableFilter | DateTime | Null,
? gamesKnown?: GameListRelationFilter,
? table?: TableNullableRelationFilter | TableWhereInput | Null,
? goingTo?: TableNullableRelationFilter | TableWhereInput | Null
},
data: {
relief: {
disconnect: true
},
dealer: {
connect: {
id: 201
}
},
dealerStartTime: new Date("2024-10-17T21:08:47.547Z")
}
}

Argument `where` of type DealerWhereUniqueInput needs at least one of `id` arguments. Available options are marked with ?.
PrismaClientValidationError:
Invalid `prisma.table.update()` invocation:

{
where: {
id: 57,
? AND?: DealerWhereInput | DealerWhereInput[],
? OR?: DealerWhereInput[],
? NOT?: DealerWhereInput | DealerWhereInput[],
? name?: StringFilter | String,
? startTime?: DateTimeFilter | DateTime,
? breakStartTime?: DateTimeNullableFilter | DateTime | Null,
? gamesKnown?: GameListRelationFilter,
? table?: TableNullableRelationFilter | TableWhereInput | Null,
? goingTo?: TableNullableRelationFilter | TableWhereInput | Null
},
data: {
relief: {
disconnect: true
},
dealer: {
connect: {
id: 201
}
},
dealerStartTime: new Date("2024-10-17T21:08:47.547Z")
}
}

Argument `where` of type DealerWhereUniqueInput needs at least one of `id` arguments. Available options are marked with ?.
Even inside the error thrown, it is apparent that an id is indeed being passed. I'm not sure where to go from here, it seems very simple so maybe I'm missing something?
12 replies
PPrisma
Created by b0ngl0rd on 8/17/2024 in #help-and-questions
Implicit many-to-many problems
// schema
model Dealer {
id Int @id @default(autoincrement())
name String
gamesKnown Game[] // <-- this field
startTime DateTime
breakStartTime DateTime?
table Table? @relation("dealer")
goingTo Table? @relation("relief")
}

model Game {
id Int @id @default(autoincrement())
gameType String
gameName String
tables Table[]
knownBy Dealer[] // <-- this field
}
// schema
model Dealer {
id Int @id @default(autoincrement())
name String
gamesKnown Game[] // <-- this field
startTime DateTime
breakStartTime DateTime?
table Table? @relation("dealer")
goingTo Table? @relation("relief")
}

model Game {
id Int @id @default(autoincrement())
gameType String
gameName String
tables Table[]
knownBy Dealer[] // <-- this field
}
and I have this piece of code:
const dealers = () => {
const dealers: Prisma.DealerCreateInput[] = [];
for (let i = 0; i < 10; i++) {
const connect: Prisma.GameWhereUniqueInput[] = f.helpers
.arrayElements(games, { min: 1, max: 3 })
.map((game) => ({ id: game.id }));
dealers.push({
name: f.person.fullName(),
startTime: new Date(
date.setHours(f.number.int({ min: 0, max: 23 }), 0, 0, 0)
),
gamesKnown: {
connect,
},
});
}
return dealers;
};
await prisma.dealer.createMany({ // <-- error thrown at this line
data: dealers(),
});
const dealers = () => {
const dealers: Prisma.DealerCreateInput[] = [];
for (let i = 0; i < 10; i++) {
const connect: Prisma.GameWhereUniqueInput[] = f.helpers
.arrayElements(games, { min: 1, max: 3 })
.map((game) => ({ id: game.id }));
dealers.push({
name: f.person.fullName(),
startTime: new Date(
date.setHours(f.number.int({ min: 0, max: 23 }), 0, 0, 0)
),
gamesKnown: {
connect,
},
});
}
return dealers;
};
await prisma.dealer.createMany({ // <-- error thrown at this line
data: dealers(),
});
Which throws this prisma error:
Unknown argument `gamesKnown`.
at main (E:\...\my_app\prisma\seed\seed.ts:36:3) {
clientVersion: '5.17.0'
}
Unknown argument `gamesKnown`.
at main (E:\...\my_app\prisma\seed\seed.ts:36:3) {
clientVersion: '5.17.0'
}
Everything is fully typed out by the TS language server with no warnings or errors. I also double-checked my seed outputs, as well as my migrations:
❯ npx prisma migrate status
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"

2 migrations found in prisma/migrations

Database schema is up to date!
❯ npx prisma migrate status
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"

2 migrations found in prisma/migrations

Database schema is up to date!
I'm just trying to seed my database to develop against, and for some reason this is the only relational query that has truly stumped me as I have nothing to go on at this point after combing through the docs and double-checking my work. I'm looking for any hint to get past this, thanks in advance for your time.
4 replies