Skip to content

Add option to skip unnecessary SELECT after create() #4246

@ziimakc

Description

@ziimakc

Problem

Every time you do operation with prisma-client it will make unnecessary select and return value

Query:

db.log
   .create({
      data: {
         smth: 1
      },
      select: { uuid: true }, // unnecessary select, even if you delete this line
   })

Logs:

prisma:query COMMIT
prisma:query BEGIN
prisma:query INSERT INTO "public"."log" ("smth") VALUES ($1) RETURNING "public"."log"."uuid"
prisma:query SELECT "public"."log"."uuid" FROM "public"."log" WHERE "public"."log"."uuid" = $1 LIMIT $2 OFFSET $3
prisma:query COMMIT

Suggested solution

Add option to skip select after insert or update (in case of operation fail error is thrown by default)

db.log
   .create({
      data: {
         smth: 1
      },
      select: false
   })

Logs:

prisma:query COMMIT
prisma:query BEGIN
prisma:query INSERT INTO "public"."log" ("smth") VALUES ($1)"
prisma:query COMMIT

Alternative solution (breaking change)

Do not return anything after insert or update if select was not explicitly set.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions