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

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

Aperta
#7,986 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
51/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
database

Direzione di ricerca

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.

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

Descrizione

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.

Lingua principale
Java
Stelle
278
Fork
97
Merge medio
16h 46m
PR unite (30g)
265

Preparare l'ambiente

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 eclipse-dirigible/dirigible

Tutte le issue di eclipse-dirigible/dirigible

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.