Strange Prisma error when trying to seed -- meta { column_name 'for' }

I'm trying to seed the following table.
model Contract {
id String @id @default(cuid())
dueDay Int? @map("due_date") @db.TinyInt()
initialDate DateTime @map("initial_date")
endingDate DateTime? @map("ending_date")
rent Decimal @db.Decimal(7, 2)
bail Decimal @db.Decimal(7, 2)
duration Int @default(12) @db.TinyInt()
interest Decimal @default(1.00) @db.Decimal(4, 2)
arrears Decimal @default(10.00) @db.Decimal(4, 2)
witnesses Witness[]
tenant Tenant @relation(fields: [tenantId], references: [id])
tenantId String @map("tenant_id")
house House @relation(fields: [houseId], references: [id])
houseId String @map("house_id")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

@@unique([houseId, tenantId, initialDate])
@@index([houseId])
@@index([tenantId])
}
model Contract {
id String @id @default(cuid())
dueDay Int? @map("due_date") @db.TinyInt()
initialDate DateTime @map("initial_date")
endingDate DateTime? @map("ending_date")
rent Decimal @db.Decimal(7, 2)
bail Decimal @db.Decimal(7, 2)
duration Int @default(12) @db.TinyInt()
interest Decimal @default(1.00) @db.Decimal(4, 2)
arrears Decimal @default(10.00) @db.Decimal(4, 2)
witnesses Witness[]
tenant Tenant @relation(fields: [tenantId], references: [id])
tenantId String @map("tenant_id")
house House @relation(fields: [houseId], references: [id])
houseId String @map("house_id")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

@@unique([houseId, tenantId, initialDate])
@@index([houseId])
@@index([tenantId])
}
I'm using planet scale as db host and prisma is in relationMode prisma. I have no errors whatsoever when I seed the tables it's related with. I also have no errors when manually creating rows in it in prisma studio. If I try to create row with prisma.model.create, I get no erros, but also no row. But if assign the create return value to a variable, then it gives me this error:
PrismaClientKnownRequestError:
Invalid `prisma.contract.create()` invocation in
/home/fabricio/code/side-projects/t3-manager/prisma/seed.ts:108:38
105 // await prisma.pixKey.createMany({ data: generateFakePixKeysData(tenants), skipDuplicates: true });
...
→ 108 const test = await prisma.contract.create(
The provided value for the column is too long for the column's type. Column: for
...
manager/node_modules/@prisma/client/runtime/index.js:35926:16) {
code: 'P2000',
clientVersion: '4.7.1',
meta: { column_name: 'for' },
batchRequestIdx: undefined
}
PrismaClientKnownRequestError:
Invalid `prisma.contract.create()` invocation in
/home/fabricio/code/side-projects/t3-manager/prisma/seed.ts:108:38
105 // await prisma.pixKey.createMany({ data: generateFakePixKeysData(tenants), skipDuplicates: true });
...
→ 108 const test = await prisma.contract.create(
The provided value for the column is too long for the column's type. Column: for
...
manager/node_modules/@prisma/client/runtime/index.js:35926:16) {
code: 'P2000',
clientVersion: '4.7.1',
meta: { column_name: 'for' },
batchRequestIdx: undefined
}
There is no such column ( for ) in any table. What could it be?
3 Replies
word
word2y ago
Please feel free to ask for any additional information. I'd really appreciate any help.
cyremur
cyremur2y ago
I've only seen that with too long Auth Tokens before, the solution there was @db.text annotation for more string space in mysql Maybe go to single creates instead of createmany so you can look which dataset fails and find an anomaly?
word
word2y ago
I actually already did this. Otherwise it just rusn as if it's ok.
await prisma.contract.create({
data: {
dueDay: faker.datatype.number({ min: 0, max: 31 }),
initialDate: faker.date.between(faker.date.recent(15), faker.date.soon(15)),
rent: faker.datatype.number({min: 400, max: 1200, precision: 2}),
bail: faker.datatype.number({min: 400, max: 1200, precision: 2}),
duration: faker.helpers.maybe(faker.datatype.number.bind(faker, { min: 12, max: 30 }), { probability: .1 }) || 12,
interest: 1,
arrears: 10,
house: {create: generateFakeHousesData(1)[0]},
tenant: { create: generateFakeTenantsData(1)[0] },
witnesses: {
createMany: {
data: generateFakeWitnessData(2)
}}
}
})
await prisma.contract.create({
data: {
dueDay: faker.datatype.number({ min: 0, max: 31 }),
initialDate: faker.date.between(faker.date.recent(15), faker.date.soon(15)),
rent: faker.datatype.number({min: 400, max: 1200, precision: 2}),
bail: faker.datatype.number({min: 400, max: 1200, precision: 2}),
duration: faker.helpers.maybe(faker.datatype.number.bind(faker, { min: 12, max: 30 }), { probability: .1 }) || 12,
interest: 1,
arrears: 10,
house: {create: generateFakeHousesData(1)[0]},
tenant: { create: generateFakeTenantsData(1)[0] },
witnesses: {
createMany: {
data: generateFakeWitnessData(2)
}}
}
})
` Also tried to simply type some values to see if the problem was being caused by faker's data. But the result is always the same :/
Want results from more Discord servers?
Add your server