Prisma1: Enum property is "undefined" through prisma client

Created on 22 Sep 2018  路  9Comments  路  Source: prisma/prisma1

Hi guys!

Describe the bug
I create type User with enum Gender

enum Gender {
    MALE
    FEMALE
}

type User {
    id: ID! @unique
    name: String!
    gender: Gender!
}

Deploy to demo server and client generation passed successful
Next I create new User and want receive gender property

import { prisma } from './generated/prisma'

async function main() {
    const user = await prisma.createUser({
        name: 'Denis',
        gender: 'MALE'
    })

    console.log(user.gender)
}

main()

But user.gender is undefined, property gender not exists in user

To Reproduce
I create repo with this bug:

  1. clone [email protected]:4urbanoff/prisma-enum-bug.git
  2. run npm i
  3. run npm run bug or Launch program in vscode debugger
  4. See error 馃お

Expected behavior
Expected user.gender === 'MALE'

Screenshots
image
image

Versions

Additional context
The problem is also stably reproduced in the local environment, e.g docker + mysql or docker + postgres.

bu2-confirmed areclient

Most helpful comment

This bug has returned in version 1.25.7. I'm using Go client generator.

All 9 comments

Same here, Prisma Client don't return ENUM value. Any help?

Hi, thanks for the great bug report. This is a bug and we'll look into this soon!

Thanks!

This fix is available in the stable version - 1.18.1 - npm install -g prisma 馃帀

This bug has returned in version 1.25.7. I'm using Go client generator.

I had the same problem with user permissions but when my users sign up , i just defined the permission in the data mutation like this:
permissions:{ set:['OWNER']}
and it works correctly. You can just define a const outside from the request and put it there

I'm also facing the same bug, with the go client and it might also be related to #4463 . @pckhoi have you found a solution?

Not using enum?

That's what I did as well but I meant one using the enum list

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

MitkoTschimev picture MitkoTschimev  路  3Comments

Fi1osof picture Fi1osof  路  3Comments

schickling picture schickling  路  3Comments

hoodsy picture hoodsy  路  3Comments