data-structures: a same-model manyToOne's declared foreignKey is not enforced - a write naming a non-existent target id is stored
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipse-dirigible/dirigible のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
eclipse-dirigible/dirigible#7958 ·
メンテナーはふだん 1 日以内に返信
-
intent: a create-from without fromStatus answers 200 on a missing or unknown source id (no 400/404)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
eclipse-dirigible/dirigible#7945 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
eclipse-dirigible/dirigible#7891 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
eclipse-dirigible/dirigible#6538 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
eclipse-dirigible/dirigible#4812 ·
メンテナーはふだん 1 日以内に返信
eclipse-dirigible/dirigible の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
checkstyle/checkstyle#22153 ·
メンテナーはふだん 1 日以内に返信
-
Documentation Needs Triage
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
frankframework/frankframework#11908 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ome/ome-codecs#48 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
tonihele/OpenKeeper#672 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
eclipse-ee4j/angus-mail#224 ·