diff --git a/crates/horizon-world/src/datafix/dynamic.rs b/crates/horizon-world/src/datafix/dynamic.rs index a831f07ab..23e50e602 100644 --- a/crates/horizon-world/src/datafix/dynamic.rs +++ b/crates/horizon-world/src/datafix/dynamic.rs @@ -214,8 +214,10 @@ pub fn copy_field(from: &Tag, field: &str, to: &mut Tag, to_field: &str) { set(to, to_field, v.clone()); } } +/// `Dynamic.equals(emptyMap())`: the map a record remembers it was read from +/// (see `datafix::mark_read`) is not part of the value. pub fn is_empty_map(tag: &Tag) -> bool { - matches!(tag, Tag::Compound(c) if c.is_empty()) + matches!(tag, Tag::Compound(c) if c.keys().all(|k| *k == key(super::LAST_READ))) } /// `Dynamic.orElseEmptyMap` of an optional field. pub fn or_empty_map(tag: Option<&Tag>) -> Tag { diff --git a/crates/horizon-world/src/datafix/mod.rs b/crates/horizon-world/src/datafix/mod.rs index 28ec619b3..ad5c6f342 100644 --- a/crates/horizon-world/src/datafix/mod.rs +++ b/crates/horizon-world/src/datafix/mod.rs @@ -105,7 +105,7 @@ impl Cx<'_> { /// writing lays the typed fields over it. A typed field that a fix drops (by /// casting to a type without it) therefore comes back on write with its value /// from that read. Each entity keeps that map under this key while fixes run. -const LAST_READ: &str = "\u{0}last_read"; +pub(crate) const LAST_READ: &str = "\u{0}last_read"; /// Remember a record's current fields as the map it was read from. pub fn mark_read(e: &mut Tag) {