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

Generated freezed file has undefined class error #96

Closed
dannyatthaya opened this issue Jan 10, 2023 · 2 comments · Fixed by #98
Closed

Generated freezed file has undefined class error #96

dannyatthaya opened this issue Jan 10, 2023 · 2 comments · Fixed by #98
Labels
bug Something isn't working

Comments

@dannyatthaya
Copy link

dannyatthaya commented Jan 10, 2023

When I run the dart run build_runner build command, the generated file has errors which is Undefined class '$PrismaNullCopyWith'. This happens when you have prisma scheme nullable field (everything works out when you don't have nullable field).

The dependencies that I have is:

dependencies:
  orm: ^2.6.0
dev_dependencies:
  build_runner: ^2.3.3
  freezed: ^2.3.2
  json_serializable: ^6.5.4

The scheme that I have is:

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

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String
  post      Post?    @relation(fields: [postId], references: [id])
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  postId    Int
}

model Post {
  id        Int      @id @default(autoincrement())
  name      String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  User      User[]
}

Here is the screenshot of the errors:
image

@medz medz added the bug Something isn't working label Jan 10, 2023
@medz
Copy link
Owner

medz commented Jan 10, 2023

@dannyatthaya There is a temporary fix:

build.yaml

targets:
  $default:
    builders:
      freezed:
        options:
          copy_with: false
          equal: false

I will fix this problem in the next version as soon as possible.

@medz
Copy link
Owner

medz commented Jan 10, 2023

@dannyatthaya Fixed in 2.6.1 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants