Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[ORM] CreateRelationField typing is missing when creating a delegated Model from a polymorphic Model

Aperta
#2,753 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
database

Direzione di ricerca

Reproduce with the example schema: Main carrying @@delegate(type) and Sub extends Main, then inspect the generated typing for zenstack.sub.create and check where CreateRelationField should be applied to the inherited item and the Sub-only group. The generator that expands delegate/polymorphic models and their relations produces these types; compare what it emits for Sub against a non-delegated model with the same relations. Done means db.sub.create({ data: { item, group } }) exposes the usual connect/create relation fields with correct types. The payload names no file, so locating the type-generation code is part of the work.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description and expected behavior
When wanting to create a new model with the create or createMany methods on a submodel of a delegated model (so Main has the @@delegate and Sub is a delegate of Main and you want to create a Sub entity) and this sub model has a relation the usual CreateRelationField typing is missing on all relation fields and only will be undefined.

Environment (please complete the following information):

  • ZenStack version: 3.8.3
  • Database type: PostgreSQL
  • Node.js/Bun version: 1.3.14
  • Package manager: Bun

Example schema

model Main with Base {
  item   Item   @relation(fields: [itemId], references: [id], onDelete: Cascade)
  itemId String

  @@unique([permissionId, itemId])
  @@delegate(type)
}

model Sub extends Main {
  group   Group  @relation(fields: [groupId], references: [id], onDelete: Cascade)
  groupId String
}

and then creating a Sub via zenstack.sub.create:

      await db.sub.create({
        data: {
          item: // <-- this is undefined and untyped
          group: // <-- aswell as relation lying directly on the Sub
        },
      })

usually there will be functions like connect, create, ...

Lingua principale
TypeScript
Stelle
2.9k
Fork
157
Merge medio
11h 42m
PR unite (30g)
20

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zenstackhq/zenstack

Tutte le issue di zenstackhq/zenstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.