Skip to main content

Crate openehr_postgresql

Crate openehr_postgresql 

Source
Expand description

openEHR persistence for PostgreSQL 18.

This crate supplies one Dialect. Everything else — the storage model, the projection from openEHR objects onto rows, the commit rules, the conformance suite — lives in openehr_store, which all five engine crates share. A dialect owns four things and no more: type spellings, identifier quoting, placeholder style, and how the engine enforces append-only.

§Conformance level: Schema

This crate emits DDL, and that DDL has been executed against PostgreSQL 18: five tables and seven indexes created, the script re-applied as a no-op, foreign keys enforced, and both append-only tables observed refusing UPDATE and DELETE with a row present and unchanged afterwards. openehr-store/scripts/verify-schema.sh postgresql reproduces it from a fresh container.

It does not contain a store: there is no driver dependency, no connection handling, and no implementation of openehr_store::Store.

That is stated plainly because the sibling FHIR monorepo in this repository carries an audit finding (F-01) for six READMEs that claimed a working store, a CLI, and 7,399 round-tripped resources in ports where none of it existed. See spec/conformance.md for what each level means.

use openehr_postgresql::PostgresqlDialect;
use openehr_store::{ColTy, Dialect, ddl_script};

let sql = ddl_script(&PostgresqlDialect);
assert!(sql.contains("CREATE TABLE IF NOT EXISTS \"openehr_version\""));
// Canonical JSON is text, not `jsonb` — see `col_sql` (`M3.43`, `D-08`).
assert_eq!(PostgresqlDialect.col_sql(ColTy::Json), "text");
assert_eq!(PostgresqlDialect.col_sql(ColTy::InstantUtc), "timestamptz");
// …while the authoritative one is text, so the lexical form survives.
assert_eq!(PostgresqlDialect.col_sql(ColTy::Instant), "text");

Structs§

PostgresqlDialect
The PostgreSQL dialect.