test(schema): assert fully-open RANGE (both endpoints null) survives V69 CHECKs

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 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-27 09:34:29 +02:00
parent c9fb14fd49
commit ae674b14d4

View File

@@ -562,6 +562,25 @@ class MigrationIntegrationTest {
assertThat(rows).isEqualTo(1); 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 @Test
void v69_rangeOrderCheck_rejectsEndBeforeStart() { void v69_rangeOrderCheck_rejectsEndBeforeStart() {
UUID docId = createDocumentWithDate("1943-05-12"); UUID docId = createDocumentWithDate("1943-05-12");