Skip to content
This repository has been archived by the owner on Oct 9, 2022. It is now read-only.

idFields of model is undefined #36

Open
kpusmo opened this issue Sep 15, 2021 · 2 comments
Open

idFields of model is undefined #36

kpusmo opened this issue Sep 15, 2021 · 2 comments

Comments

@kpusmo
Copy link

kpusmo commented Sep 15, 2021

I get the following error when running the script against my schema:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at /home/kpusmo/WebstormProjects/foo/node_modules/prisma-schema-transformer/dist/transformer.js:55:22
    at Object.Immer.produce (/home/kpusmo/WebstormProjects/foo/node_modules/immer/dist/immer.cjs.development.js:791:20)
    at transformModel (/home/kpusmo/WebstormProjects/foo/node_modules/prisma-schema-transformer/dist/transformer.js:53:37)
    at /home/kpusmo/WebstormProjects/foo/node_modules/prisma-schema-transformer/dist/transformer.js:83:32
    at Array.map (<anonymous>)
    at Object.dmmfModelTransformer (/home/kpusmo/WebstormProjects/foo/node_modules/prisma-schema-transformer/dist/transformer.js:83:19)
    at fixPrismaFile (/home/kpusmo/WebstormProjects/foo/node_modules/prisma-schema-transformer/dist/index.js:43:34)
    at async /home/kpusmo/WebstormProjects/foo/node_modules/prisma-schema-transformer/bin.js:56:17

My schema is:

model foo_bar {
  id      String  @id @default(uuid())
  bar_foo String
  baz     String?
}

I've added console.log(model) to transformer.js:54, and the field is actually missing from the model:

{
  name: 'foo_bar',
  isEmbedded: false,
  dbName: null,
  fields: [
    {
      name: 'id',
      kind: 'scalar',
      isList: false,
      isRequired: true,
      isUnique: false,
      isId: true,
      isReadOnly: false,
      type: 'String',
      hasDefaultValue: true,
      default: [Object],
      isGenerated: false,
      isUpdatedAt: false
    },
    {
      name: 'bar_foo',
      kind: 'scalar',
      isList: false,
      isRequired: true,
      isUnique: false,
      isId: false,
      isReadOnly: false,
      type: 'String',
      hasDefaultValue: false,
      isGenerated: false,
      isUpdatedAt: false
    },
    {
      name: 'baz',
      kind: 'scalar',
      isList: false,
      isRequired: false,
      isUnique: false,
      isId: false,
      isReadOnly: false,
      type: 'String',
      hasDefaultValue: false,
      isGenerated: false,
      isUpdatedAt: false
    }
  ],
  isGenerated: false,
  primaryKey: null,
  uniqueFields: [],
  uniqueIndexes: []
}

Am I missing something?

@allyusd
Copy link

allyusd commented Dec 11, 2021

It's possible because you use primes 3, wait for a new version release, or try my temporary patch https://github.com/allyusd/prisma-schema-transformer

@focux
Copy link

focux commented Jun 15, 2022

It's possible because you use primes 3, wait for a new version release, or try my temporary patch https://github.com/allyusd/prisma-schema-transformer

This worked for me. If anyone wants to use it can do it by installing it directly using the repo link. Thank you @allyusd!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants