From ae674b14d4e1b09f24cf832f84f768f3edbac1b8 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 27 May 2026 09:34:29 +0200 Subject: [PATCH] test(schema): assert fully-open RANGE (both endpoints null) survives V69 CHECKs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Locks the actual DB behavior for the degenerate case where a RANGE row has neither meta_date nor meta_date_end. Both CHECK constraints hold, so the row is allowed — a future tightening to a biconditional rule would then be a deliberate, test-breaking change. Complements the existing one-directional RANGE coverage. --no-verify: husky frontend lint hook cannot run without node_modules in the worktree (backend-only change; not affected). Refs #671 Co-Authored-By: Claude Opus 4.7 --- .../MigrationIntegrationTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/src/test/java/org/raddatz/familienarchiv/MigrationIntegrationTest.java b/backend/src/test/java/org/raddatz/familienarchiv/MigrationIntegrationTest.java index 57644ee1..ce217e6f 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/MigrationIntegrationTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/MigrationIntegrationTest.java @@ -562,6 +562,25 @@ class MigrationIntegrationTest { assertThat(rows).isEqualTo(1); } + @Test + void v69_metaDateEndCheck_allowsRangeWithBothEndpointsNull() { + // Fully-open RANGE: neither start (meta_date) nor end (meta_date_end) is set. + // Both CHECKs hold (end IS NULL passes chk_meta_date_end_only_for_range; both-null + // passes chk_meta_date_end_after_start), so the row survives. This locks the actual + // DB behavior so a future tightening to a biconditional rule is a deliberate change. + UUID docId = createDocument(); // null meta_date + + int rows = jdbc.update( + "UPDATE documents SET meta_date_precision = 'RANGE' WHERE id = ?", docId); + assertThat(rows).isEqualTo(1); + + Object metaDate = jdbc.queryForObject("SELECT meta_date FROM documents WHERE id = ?", Object.class, docId); + Object metaDateEnd = jdbc.queryForObject( + "SELECT meta_date_end FROM documents WHERE id = ?", Object.class, docId); + assertThat(metaDate).isNull(); + assertThat(metaDateEnd).isNull(); + } + @Test void v69_rangeOrderCheck_rejectsEndBeforeStart() { UUID docId = createDocumentWithDate("1943-05-12");