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

data-structures: a same-model manyToOne's declared foreignKey is not enforced - a write naming a non-existent target id is stored

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
51/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java
領域
database

調査の方向性

Start by tracing how the synchronizer creates tables from the generated .schema and how generated controllers handle writes for same-model manyToOne relations. Compare the declared foreignKey with the stored Kind and PriceList values described here. Done means a write with a nonexistent target id is rejected, either by a database constraint or controller check; the issue does not name specific source files or tests.

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

説明

What happens

A same-model manyToOne (both entities in one intent, one .schema) accepts an id that does not exist. The generated .schema declares the relation as a foreignKey structure, but no constraint stops the write - on a FRESH dirigiblelabs/dirigible:14.95.0 instance (tables created by the synchronizer from that .schema):

customers.intent:  - { name: Kind, kind: manyToOne, to: CustomerKind, init: 1, size: 4 }   # CustomerKind seeded 1, 2
gen/customers/schema/customers.schema:
  {"name": "Customer_Kind", "type": "foreignKey", "table": "CUSTOMERS_CUSTOMER", "constraintName": "Customer_Kind",
   "columns": "CUSTOMER_KIND", "referencedTable": "CUSTOMERS_CUSTOMER_KIND", "referencedColumns": "CUSTOMER_KIND_ID"}

POST /services/java/customers/gen/customers/api/customer/CustomerController {"Name":"fk probe","Kind":999} -> 200, Kind 999 stored

The same holds for PriceList (seeded 1-5, 999 stored). Found by the BusinessIntents 1.32.0 hunt (base-customers#56): a customer of Kind 999 is neither Business nor Individual, so the invoice Issue gate keyed on Customer.Kind == 1 (the registration-number requirement) never applies - an invoice was ISSUED to a business with no ЕИК.

Expected

Either the declared foreign key exists in the database for a same-model relation (the write fails, ideally as a 400 naming the relation rather than a 500), or the generated controller checks that the target row exists. A cross-model to-one has no FK by design; a same-model one is in the same .schema and could.

Workaround in the module

checks: - { kind: forbidWhen, when: ["Kind != null", "Kind.name == null"] } per relation (the #7555 null test over a one-hop path) - one check per relation of every entity, which a schema constraint would make unnecessary.

主要言語
Java
スター
278
フォーク
97
平均マージ
17時間 19分
マージ済み PR(30日)
261

環境構築

はじめの一歩

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

eclipse-dirigible/dirigible のほかの issue

eclipse-dirigible/dirigible の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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