Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Feature Request] a foreign constraint attribute for scalar fields not implying a relation mapping

オープン
#2,638 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript
領域
database

調査の方向性

Language-design request for the ZModel schema DSL: a new @foreign attribute must be threaded from attribute declaration through schema validation to generated migration DDL. No file or test is named, so start where built-in attributes like @relation are declared, parsed and validated, then follow migration generation. Open semantic question: SQL foreign keys require a unique referenced column, so references: [kind] needs a design decision; done means the schema compiles and the migration emits the constraint.

索引モデルが issue の本文から書いたものです。

説明

Problem

model ModelA {
 id Int,
 name String
 bKind String        //should matches a value that exists in ModelB.kind
}

model ModelB {
 id Int,
 name String
 kind String  //this is not unique and can't identify a single ModelB row
}

Unfortunately, AFAIK the only current way of describing a FK is through a @relation attribute that enforce matching an unique and effective object, that should be present in the linked model.
That's not ideal when one just want to ensure scalars consistency from the described zmodel.

Proposal
A new @foreign attribute allowing to describe a simple FK constraint would be nice
i.e:

model TableA {
 id Int,
 name String
 bKind String       @foreign(fields:[bKind], references:[kind], from: ModelB)
}

Describe alternatives you've considered
Adding custom SQL to create the FK in a migration. But, IMHO, the ORM model should allow describing simple FK and abstract their creation.

主要言語
TypeScript
スター
2.9k
フォーク
157
平均マージ
2日 46分
マージ済み PR(30日)
17

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

zenstackhq/zenstack のほかの issue

zenstackhq/zenstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。