Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#2,753 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
database

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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, ...

Ngôn ngữ chính
TypeScript
Star
2.9k
Fork
157
Merge trung bình
4 ngày 5 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của zenstackhq/zenstack

Tất cả issue của zenstackhq/zenstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.