Skip to content

Query engine panics when the ID used to create a record and the actual ID in the database are different #2687

@divyenduz

Description

@divyenduz

Bug description

If the ID of a row is different in the database from the ID used to create that row, Query engine panics with:

Invalid response data: the query result was required, but an empty Object((Weak)) was returned instead

How to reproduce

  1. Use this SQL schema to reproduce
DROP TABLE IF EXISTS `User`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `User` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
  1. Use this schema.prisma to generate the client.
model User {
    id   Int    @id
    name String
}

Note that the schema is missing the autoincrement that is present in the SQL

  1. Send the following query through the client
const data = await prisma.user.create({
  data: {
    id: 0,
    name: 'Alice',
  },
})
  1. Observe the error
Invalid response data: the query result was required, but an empty Object((Weak)) was returned instead

Here is a video that demonstrates this error: https://www.loom.com/share/40f6c9f4392a4f75a246d34319d710d8

Expected behavior

Possibly a known error?
Or a runtime failure that detects the client being out of sync with the schema.

Prisma information

@prisma/cli          : 2.0.0-beta.8

Additional Information

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions