diff options
| author | tv <tv@krebsco.de> | 2026-11-29 15:02:23 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 14:59:15 +0000 |
| commit | a0f22c88d54d351b060c2d0d9f0a8cbf5f412ba2 (patch) | |
| tree | d65495f9ed222fb978bc09afcb3bd644a99aa7c5 /src/view.rs | |
| parent | 83f1d36bbaeb193ae1c663b5b1b7956661ecac8c (diff) | |
enstate: --migrate, renames both ways, kept entries
What a generation sees of a snapshot accepted under another schema:
same name and type, renamedFrom, a rename in the stored schema read
backwards, and entries kept, with their types, in the snapshot's kept/.
Plans start from what is seen, and store it under the running schema;
a generation change rewrites no snapshot. --migrate (and --dry-run)
says what each channel sees, refuses for required slots nothing fills,
puts the views in place and runs their reactions; --materialize and
--status go by what is seen, too. A view made from an unfilled
required slot isn't there. The rollback cases of migrations.md that
need no converters or steps are tests.
Diffstat (limited to 'src/view.rs')
| -rw-r--r-- | src/view.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/view.rs b/src/view.rs index b7bab6c..bd4b8f5 100644 --- a/src/view.rs +++ b/src/view.rs @@ -17,8 +17,9 @@ use crate::scratch::Scratch; /// would be, the others as they are. pub type Entries<'a> = BTreeMap<&'a str, &'a Content>; -/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if it -/// is an entry's own and that entry isn't there. +/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if a +/// required slot it is made from is unfilled, or it is an entry's own and that entry +/// isn't there. pub fn render( schema: &Schema, name: &str, @@ -31,6 +32,13 @@ pub fn render( .get(address.channel.as_str()) .and_then(|content| content.get(&address.slot)) }; + // A view made from a required slot that is unfilled isn't there (docs/design.md, + // section 7). + if view.from.iter().any(|address| { + schema.slot(address).is_some_and(|slot| slot.required) && entry(address).is_none() + }) { + return Ok(None); + } match &view.renderer { None => { let address = &view.from[0]; |
