Skip to content

regression: nested create/connect in delegate model requires reference fields #1894

@chunkerchunker

Description

@chunkerchunker

Zenstack version 2.8.0 changed the type signature for nested creates/connects on delegates, incorrectly requiring referenced identifiers.

With the following schema:

model A {
  id Int @id @default(autoincrement())
  b  B[]
}

model B {
  id   Int    @id @default(autoincrement())
  a    A      @relation(fields: [aId], references: [id])
  aId  Int

  type String
  @@delegate(type)
}

model C extends B {
  f String?
}

I expect to be able to call something like:

db.c.create({ data: { a: { connect: { id: 0 } } } });

But as of version 2.8.0, Zenstack defines the data signature (in the generated .logical-prisma-client/runtime/index-fixed.d.ts) as the following (requiring the aId reference property):

export type CCreateInput = {
    aId: number

    f?: string | null
    a: ACreateNestedOneWithoutDelegate_aux_A_b_CInput
};

In previous versions, Zenstack defined it as expected:

export type CCreateInput = {

    f?: string | null
    a: ACreateNestedOneWithoutDelegate_aux_A_b_CInput
};

Environment:

  • ZenStack version: >= 2.8.0
  • Prisma version: any
  • Database type: any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions