From 7a1f44dd7e67c324f2f7892516967cb25eef1371 Mon Sep 17 00:00:00 2001 From: Jimisola Laursen Date: Tue, 23 Jun 2026 23:08:22 +0200 Subject: [PATCH] fix(schema): allow ANNOTATION_TYPE in storage CHECK constraints #419 fixed annotations.schema.json's elementKind enum but missed two other independent copies of the same enum that also needed the fix: - storage/schema.py's annotations_impls/annotations_tests CHECK constraints -- these silently dropped the row via `INSERT OR IGNORE` with no warning logged, so a requirement/SVC with an ANNOTATION_TYPE annotation location passed schema validation but then vanished from the database with no error at all - export_output.schema.json's own element_kind enum copy (used by the export command's output validation, tested by test_output_schemas.py) Found by re-running reqstool-java-annotations#166's CI: the schema error from #419 was gone, but ANNOTATIONS_001 (the requirement self-applied to the Requirements/SVCs annotation declarations themselves) still showed "not implemented" with no error -- the CHECK constraint silently swallowing the insert. Signed-off-by: Jimisola Laursen --- src/reqstool/models/annotations.py | 2 +- src/reqstool/resources/schemas/v1/export_output.schema.json | 2 +- src/reqstool/storage/schema.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reqstool/models/annotations.py b/src/reqstool/models/annotations.py index a65673ad..3c4620ba 100644 --- a/src/reqstool/models/annotations.py +++ b/src/reqstool/models/annotations.py @@ -10,7 +10,7 @@ class AnnotationData(BaseModel): model_config = ConfigDict(frozen=True) - element_kind: str # FIELD, METHOD, CLASS, ENUM, INTERFACE, RECORD + element_kind: str # FIELD, METHOD, CLASS, ENUM, INTERFACE, ANNOTATION_TYPE, RECORD fully_qualified_name: str diff --git a/src/reqstool/resources/schemas/v1/export_output.schema.json b/src/reqstool/resources/schemas/v1/export_output.schema.json index f717e1a1..b3c2f4c3 100644 --- a/src/reqstool/resources/schemas/v1/export_output.schema.json +++ b/src/reqstool/resources/schemas/v1/export_output.schema.json @@ -338,7 +338,7 @@ "properties": { "element_kind": { "type": "string", - "enum": ["FIELD", "METHOD", "CLASS", "ENUM", "INTERFACE", "RECORD"], + "enum": ["FIELD", "METHOD", "CLASS", "ENUM", "INTERFACE", "ANNOTATION_TYPE", "RECORD"], "description": "Kind of code element annotated" }, "fully_qualified_name": { diff --git a/src/reqstool/storage/schema.py b/src/reqstool/storage/schema.py index 8a98569e..297e1856 100644 --- a/src/reqstool/storage/schema.py +++ b/src/reqstool/storage/schema.py @@ -97,7 +97,7 @@ req_urn TEXT NOT NULL, req_id TEXT NOT NULL, element_kind TEXT NOT NULL CHECK (element_kind IN ( - 'FIELD', 'METHOD', 'CLASS', 'ENUM', 'INTERFACE', 'RECORD' + 'FIELD', 'METHOD', 'CLASS', 'ENUM', 'INTERFACE', 'ANNOTATION_TYPE', 'RECORD' )), fqn TEXT NOT NULL, PRIMARY KEY (req_urn, req_id, element_kind, fqn), @@ -108,7 +108,7 @@ svc_urn TEXT NOT NULL, svc_id TEXT NOT NULL, element_kind TEXT NOT NULL CHECK (element_kind IN ( - 'FIELD', 'METHOD', 'CLASS', 'ENUM', 'INTERFACE', 'RECORD' + 'FIELD', 'METHOD', 'CLASS', 'ENUM', 'INTERFACE', 'ANNOTATION_TYPE', 'RECORD' )), fqn TEXT NOT NULL, PRIMARY KEY (svc_urn, svc_id, element_kind, fqn),