Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.6.0 Broke some of my update queries #3497

Closed
fchu opened this issue Sep 1, 2020 · 22 comments
Closed

2.6.0 Broke some of my update queries #3497

fchu opened this issue Sep 1, 2020 · 22 comments
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client
Milestone

Comments

@fchu
Copy link

fchu commented Sep 1, 2020

Bug description

Upgrading to 2.6.0 required me to rewrite my upsert/update queries.
After doing so, engine will complain about missing fields while compile-time check doesn't.

How to reproduce

  1. Setup:
model User {
  id         Int      @default(autoincrement()) @id
  externalId String   @default(dbgenerated())

  displayName String
  imageUrl    String?

  source  SourceInfo?
}

model SourceInfo {
  baseUrl String @id

  user   User? @relation(fields: [userId], references: [id])
  userId Int?  @unique
}

Queries:

export const updateOne = async (
  userId: number,
  displayName: string,
  canonicalUrl: string,
  imageUrl: string | null) => {
  return prisma().user.update({
    where: {
      id: userId,
    },
    data: {
      displayName,
      imageUrl,
      source: {
        update: {
          baseUrl: canonicalUrl,  // [A]
        },
      },
    }
  });
};
  1. Upgrade to 2.6.0 & generate client
npm install @prisma/client
npm install --save-dev @prisma/cli
npx prisma generate
  1. Observe compilation error referring to line [A].
Type 'string' is not assignable to type 'StringFieldUpdateOperationsInput | undefined'
  1. Fix compilation to replace line [A] as follows:
          baseUrl: canonicalUrl,

to

          baseUrl: { set: canonicalUrl },
  1. Get error when calling updateOne:
Missing a required value at `Mutation.updateOneUser.data.UserUpdateInput.imageUrl`

Expected behavior

  1. Ideally update should not introduce unannounced breaking changes
  2. Update should succeed, like it did on 2.5.1

Prisma information

2.5.1 to 2.6.0

Environment & setup

  • OS: macOS 10.15.6
  • Database: PostgreSQL
  • Node.js version: v12.16.2
  • Prisma version:
@prisma/cli          : 2.6.0
Current platform     : darwin
Query Engine         : query-engine 650b5d0348ec38ae61e1e7db69bb54808418ede4 (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine     : migration-engine-cli 650b5d0348ec38ae61e1e7db69bb54808418ede4 (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core 650b5d0348ec38ae61e1e7db69bb54808418ede4 (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary        : prisma-fmt 650b5d0348ec38ae61e1e7db69bb54808418ede4 (at node_modules/@prisma/cli/prisma-fmt-darwin)
Studio               : 0.272.0
@janpio
Copy link
Member

janpio commented Sep 2, 2020

Thanks for reporting this, certainly unexpected. Someone will look into this as soon as possible. Looks like an unwanted regression on first sight.

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/regression A reported bug in functionality that used to work before. labels Sep 2, 2020
@SharadKumar
Copy link

Yes, I confirm... broke on my Json? column too... rolling back to 2.5.1 fixed them!

Schema:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
model Customer {
  id            String    @default(cuid()) @id
  email         String
  name          String?
  address       Json?
  timezone      String?
  createdAt     DateTime  @default(now()) @map(name: "created_at")
  updatedAt     DateTime  @default(now()) @map(name: "updated_at")
}

Mutation:

const customer = await prisma.customer.update({
            data: {address},
           ...
          })

Error:

You've encountered a problem. �
[Invalid �[1m`prisma.customer.update()`�[
 invocation in�[
[�[webpack-internal:///./pages/api/profile.ts:57:52�[�[ Failed to validate the query `Error occurred during query validation & transformation: Mutation (object) ↳ updateOneCustomer (field) ↳ data (argument) ↳ CustomerUpdateInput (object) ↳ address (field) ↳ 
Value types mismatch. 
Have: String("{\"line1\":\"123\",\"unit\":\"\",\"city\":\"\",\"state\":\"\",\"pincode\":\"\"}"), 
want: Object((Weak))` at `.Mutation.updateOneCustomer.data.CustomerUpdateInput.address`

@Jolg42 Jolg42 added this to the Release 2.7.0 milestone Sep 2, 2020
@jonahsnider
Copy link

jonahsnider commented Sep 2, 2020

Having (vaguely) similar errors after updating to 2.6.0 when updating a DateTime value called MY_DATE_TIME_VALUE in my model MY_MODEL:

Error while running command: Error: Error in query graph construction: QueryParserError(ObjectValidationError { object_name: "Mutation", inner: FieldValidationError { field_name: "updateOneMY_MODEL", inner: ArgumentValidationError { argument: "data", inner: ObjectValidationError { object_name: "MY_MODELUpdateInput", inner: FieldValidationError { field_name: "MY_DATE_TIME_VALUE", inner: ValueTypeMismatchError { have: String("2020-09-02T07:39:49.913Z"), want: Object((Weak)) } } } } } })
    at /srv/node_modules/@prisma/engine-core/dist/NodeEngine.js:879:1
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

I slightly changed my update call but I don't think that's the cause. I'm not willing to test to confirm this.

@Jolg42 Jolg42 added tech/engines/query engine Issue in the Query Engine tech/engines Issue for tech Engines. labels Sep 2, 2020
@Jolg42 Jolg42 self-assigned this Sep 2, 2020
@Jolg42 Jolg42 added bug/2-confirmed Bug has been reproduced and confirmed. tech/typescript Issue for tech TypeScript. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. tech/engines/query engine Issue in the Query Engine tech/engines Issue for tech Engines. labels Sep 2, 2020
@Jolg42 Jolg42 added the topic: client types Types in Prisma Client label Sep 2, 2020
@Jolg42
Copy link
Member

Jolg42 commented Sep 2, 2020

Thanks for the issue, we now have a fix coming soon, so I'll update you when you can try it 😃

@johhansantana
Copy link

Thanks for the issue, we now have a fix coming soon, so I'll update you when you can try it 😃

Is there any unreleased version that we can use in the meantime that fixes this issue?

@Jolg42
Copy link
Member

Jolg42 commented Sep 3, 2020

So we have a fix in our development build 2.6.1-dev.2 (not recommended for production usage) it will be part of the official 2.6.1 patch release soon.

@Jolg42
Copy link
Member

Jolg42 commented Sep 3, 2020

This fix is now available in the 2.6.1 official patch 😃

@Jolg42 Jolg42 closed this as completed Sep 3, 2020
@JuanM04
Copy link

JuanM04 commented Sep 3, 2020

I updated Prisma to v2.6.1, removed my node-modules, run prisma generate, and the error persists

@Jolg42
Copy link
Member

Jolg42 commented Sep 3, 2020

@JuanM04 could you post here what is the error and code?

It would be awesome to have a minimal reproduction 😃

@JuanM04
Copy link

JuanM04 commented Sep 3, 2020

The error is the same that @fchu reported:

Missing a required value at `Mutation.updateOneUser.data.UserUpdateInput.imageUrl`

The problem happens when I try (using the example above):

prisma.user.update({
  where: {id: 1},
  data: { imageUrl: null }
})

Before 2.6.0, that was working, but now it isn't

@Jolg42
Copy link
Member

Jolg42 commented Sep 3, 2020

Thanks @JuanM04 we will investigate that!

@Jolg42 Jolg42 reopened this Sep 3, 2020
@Jolg42
Copy link
Member

Jolg42 commented Sep 3, 2020

We have a reproduction and are working on a fix.

@vadim-shilov
Copy link

prisma 2.6.1
macOS 10.15.5
db sqlite
node 14.9.0

Mutation (object)
↳ upsertOneBook (field)
↳ update (argument)
↳ BookUpdateInput (object)
↳ availableDate (field)
↳ Value types mismatch. Have: String("2015-06-15T05:21:51.000Z"), want: Object((Weak))at.Mutation.upsertOneBook.update.BookUpdateInput.availableDate`
at PrismaClientFetcher.request (/Users/vadim/Projects/middleware/node_modules/@prisma/client/runtime/index.js:1:228179)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async run (/Users/vadim/Projects/middleware/src/parsers/index.js:37:13)

@alan345
Copy link

alan345 commented Sep 3, 2020

I guess it is related to #3512

Jolg42 added a commit that referenced this issue Sep 4, 2020
@Jolg42
Copy link
Member

Jolg42 commented Sep 4, 2020

So we have a fix in our development build 2.6.2-dev.1 (not recommended for production usage) it will be part of the official 2.6.2 patch release soon.

Jolg42 added a commit that referenced this issue Sep 4, 2020
@Jolg42
Copy link
Member

Jolg42 commented Sep 4, 2020

2.6.2 is released 😃

https://github.com/prisma/prisma/releases/tag/2.6.2

@MaksimKlepikov
Copy link

You guys forgot about upsert.
Same for upsert on 2.6.2 and nexus-plugin-prisma 0.18.2
My package.json:

  "dependencies": {
    "@nexus/schema": "^0.15.0",
    "apollo-server": "^2.17.0",
    "graphql-relay": "^0.6.0",
    "nexus-plugin-prisma": "^0.18.2"
  },
  "devDependencies": {
    "@types/graphql-relay": "^0.6.0",
    "ts-node-dev": "^1.0.0-pre.52",
    "typescript": "^4.0.2"
  },
  "resolutions": {
    "@prisma/cli": "^2.6.2",
    "@prisma/client": "^2.6.2"
  }

@pantharshit00
Copy link
Contributor

@kevrat

Please open a new issue with a reproduction. I was unable to reproduce this. Also, make sure you ran prisma generate after upgrading

@MaksimKlepikov

This comment has been minimized.

@MaksimKlepikov
Copy link

Anyone using nexus-plugin-prisma. it is not related to the prisma
graphql-nexus/nexus-plugin-prisma#830

@redblue9771
Copy link

in v2.15.0
Expected value of type \"StringFieldUpdateOperationsInput\", found \"test\".

@pantharshit00
Copy link
Contributor

@redblue9771 Please open a new issue about this with a minimal reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client
Projects
None yet
Development

No branches or pull requests