diff --git a/lib/src/doc/merge.rs b/lib/src/doc/merge.rs index f7d70e0b..64fdec4c 100644 --- a/lib/src/doc/merge.rs +++ b/lib/src/doc/merge.rs @@ -16,10 +16,10 @@ impl<'a> Document<'a> { txn: &Transaction, stm: &Statement, ) -> Result<(), Error> { - // Get the ID reference - let id = self.id.as_ref(); + // Get the record id + let rid = self.id.as_ref().unwrap(); // Set default field values - self.current.to_mut().def(ctx, opt, txn, id).await?; + self.current.to_mut().def(ctx, opt, txn, rid).await?; // The statement has a data clause if let Some(v) = stm.data() { match v { @@ -55,7 +55,7 @@ impl<'a> Document<'a> { }; }; // Set default field values - self.current.to_mut().def(ctx, opt, txn, id).await?; + self.current.to_mut().def(ctx, opt, txn, rid).await?; // Carry on Ok(()) } diff --git a/lib/src/sql/value/def.rs b/lib/src/sql/value/def.rs index b128f92f..19d1d4bb 100644 --- a/lib/src/sql/value/def.rs +++ b/lib/src/sql/value/def.rs @@ -8,8 +8,6 @@ use crate::sql::value::Value; use once_cell::sync::Lazy; static RID: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("id")]); -static MTB: Lazy<[Part; 2]> = Lazy::new(|| [Part::from("meta"), Part::from("tb")]); -static MID: Lazy<[Part; 2]> = Lazy::new(|| [Part::from("meta"), Part::from("id")]); impl Value { pub async fn def( @@ -17,18 +15,8 @@ impl Value { ctx: &Runtime, opt: &Options, txn: &Transaction, - val: Option<&Thing>, + val: &Thing, ) -> Result<(), Error> { - match val { - Some(id) => { - let id = id.clone(); - let md = id.clone(); - self.set(ctx, opt, txn, RID.as_ref(), id.into()).await?; - self.set(ctx, opt, txn, MTB.as_ref(), md.tb.into()).await?; - self.set(ctx, opt, txn, MID.as_ref(), md.id.into()).await?; - Ok(()) - } - None => unreachable!(), - } + self.set(ctx, opt, txn, RID.as_ref(), val.clone().into()).await } }