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

Infinite size error on Recursive types #11

Open
omadoyeabraham opened this issue Mar 28, 2022 · 0 comments
Open

Infinite size error on Recursive types #11

omadoyeabraham opened this issue Mar 28, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@omadoyeabraham
Copy link
Contributor

omadoyeabraham commented Mar 28, 2022

Given a prisma model with some recursive relationship like below,

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

model Task {
     id    Int     @id @default(autoincrement())
     title     String
     description     String?
     completed Boolean  @default(false)
     dueDate DateTime?
     createdAt DateTime @default(now())
     parentTaskId Int?
     parentTask   Task?   @relation("ParentSubTasks", fields: [parentTaskId], references: [id])
     subTasks Task[] @relation("ParentSubTasks")
}

the generated prisma.rs contains a struct with recursive types that lead to an infinite size error.

#[derive(Clone, Serialize, Deserialize, Debug, QueryInternal)]
pub struct Task {
 ...

    pub parent_task: Option<Task>,  // RECURSIVE HERE
  
...
}

The solution would be to Box said recursive types

@omadoyeabraham omadoyeabraham added the bug Something isn't working label Mar 28, 2022
@omadoyeabraham omadoyeabraham self-assigned this Mar 28, 2022
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

No branches or pull requests

1 participant