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

deleting a record with a list field of scalar values always returns empty array #4197

Open
pantharshit00 opened this Issue Mar 15, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@pantharshit00
Copy link
Member

pantharshit00 commented Mar 15, 2019

Describe the bug
Deleting a record with a list field of scalar values always returns an empty array even though this should not be the case.

To Reproduce
Use the following datamodel and deploy a prisma instance using it:

type Item {
    id: ID! @unique
    name: String!
    description: String
    price: Float!
    quantity: Int! @default(value: "1")
    images: [String!]!
}

Run the following and observe the output:

const item = {
    name: 'Some item',
    description: 'Some description',
    price: 273.0,
    quantity: 20,
    images: [
        'http://lorempixel.com/640/480',
        'http://lorempixel.com/640/480/business',
        'http://lorempixel.com/640/480/nightlife',
    ],
}

const { id } = await prisma.createItem({ ...item, images: { set: item.images } })

const itemInDb = await prisma.item({ id })
console.log(itemInDb.images) // prints "['http://...', 'http://....', 'http://....']"

const deletedItem = await prisma.deleteItem({ id })
console.log(deletedItem.images) //  prints "[]"

Expected behaviour
Prisma should return the deleted object

Screenshots
Output of the script
image

Versions (please complete the following information):

  • Connector: Postgres
  • Prisma Server: 1.28.3
  • prisma CLI: 1.28.3
  • OS: MacOS 10.14.3
@do4gr

This comment has been minimized.

Copy link
Member

do4gr commented Mar 15, 2019

This has to do with the way we are fetching previous values during deletes. We will not fetch related nodes or list values. We might change this at some point, but for now that is intended behaviour in order to speed up the mutation.

@do4gr do4gr added kind/feature and removed bug/2-confirmed labels Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.