Postgres Time type causes "insufficient data left in message" error
mydnicq opened this issue · comments
Tadej Stanic commented
Bug description
When I have a column in Postgres with type Time
and tried to insert a Date object created from ISO 8601 string into that column. The query fails with Error #1:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError {
severity: "ERROR", parsed_severity: Some(Error), code: SqlState("08P01"), message: "insufficient data left in message",
detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None,
constraint: None, file: Some("pqformat.c"), line: Some(535), routine: Some("pq_copymsgbytes") }) }) })
I have to create a Date object otherwise I get a different error #2 :
Argument time_of_day: Got invalid value '2020-03-17T13:32:09Z' on prisma.createOnecampaign. Provided String, expected DateTime.
How to reproduce
- Have a column in Postgres with type set to
Time
. - Insert a DateObject like
new Date('2000-01-01T23:15:00Z')
into that column throughprisma.[model].create
.
Expected behavior
According to Postgres docs https://www.postgresql.org/docs/9.1/datatype-datetime.html there are several valid inputs for Time types. I'd expect that a valid ISO string like 04:05
would be sufficient to successfully execute the query.
Prisma information
model campaign {
time_of_day DateTime
}
async create(createCampaign: CampaignCreateDto) {
// Error 1
const timeOfDayAsDate = new Date(`2000-01-01T${time_of_day}`);
const data = { time_of_day: timeOfDayAsDate };
// Error 2
const data = { time_of_day };
return await this.prisma.campaign.create({
data,
});
}
Environment & setup
- OS: Mac OS
- Database: PostgreSQL v11.8
- Node.js version: v12.18.4
- Prisma version:
@prisma/cli : 2.9.0
@prisma/client : 2.9.0
Current platform : darwin
Query Engine : query-engine 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine : migration-engine-cli 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary : prisma-fmt 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/prisma-fmt-darwin)
Studio : 0.296.0
Harshit Pant commented
Closing in favour of prisma/prisma#4647