Description
With the SQLite dialect (v3), any create/update that writes null to a nullable Decimal field crashes:
TypeError: Cannot read properties of null (reading 'toString')
❯ SqliteCrudDialect.transformInput src/client/crud/dialects/sqlite.ts:102:46
❯ CreateOperationHandler.create src/client/crud/operations/base.ts:454:55
Repro
model Project {
id String @id @default(cuid())
hourlyRate Decimal?
}
await db.project.create({ data: { hourlyRate: null } }); // throws
Cause
SqliteCrudDialect.transformInput only early-returns on undefined, and the Decimal branch calls .toString() unguarded (sqlite.ts:102):
case 'Decimal':
return (value as Decimal).toString();
The Postgres dialect guards this same case:
value !== null ? value.toString() : value
Suggested fix
Mirror the Postgres guard in the SQLite dialect:
case 'Decimal':
return value !== null ? (value as Decimal).toString() : value;
Affects at least 3.6.4 through 3.9.0; current main still has the unguarded call. Happy to send a PR if useful.
Description
With the SQLite dialect (v3), any
create/updatethat writesnullto a nullableDecimalfield crashes:Repro
Cause
SqliteCrudDialect.transformInputonly early-returns onundefined, and theDecimalbranch calls.toString()unguarded (sqlite.ts:102):The Postgres dialect guards this same case:
Suggested fix
Mirror the Postgres guard in the SQLite dialect:
Affects at least 3.6.4 through 3.9.0; current
mainstill has the unguarded call. Happy to send a PR if useful.