Don’t set meta field on records

This commit is contained in:
Tobie Morgan Hitchcock 2022-04-01 11:17:19 +01:00
parent 41c44ea709
commit bf1a833a79
2 changed files with 6 additions and 18 deletions

View file

@ -16,10 +16,10 @@ impl<'a> Document<'a> {
txn: &Transaction, txn: &Transaction,
stm: &Statement, stm: &Statement,
) -> Result<(), Error> { ) -> Result<(), Error> {
// Get the ID reference // Get the record id
let id = self.id.as_ref(); let rid = self.id.as_ref().unwrap();
// Set default field values // 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 // The statement has a data clause
if let Some(v) = stm.data() { if let Some(v) = stm.data() {
match v { match v {
@ -55,7 +55,7 @@ impl<'a> Document<'a> {
}; };
}; };
// Set default field values // 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 // Carry on
Ok(()) Ok(())
} }

View file

@ -8,8 +8,6 @@ use crate::sql::value::Value;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
static RID: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("id")]); 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 { impl Value {
pub async fn def( pub async fn def(
@ -17,18 +15,8 @@ impl Value {
ctx: &Runtime, ctx: &Runtime,
opt: &Options, opt: &Options,
txn: &Transaction, txn: &Transaction,
val: Option<&Thing>, val: &Thing,
) -> Result<(), Error> { ) -> Result<(), Error> {
match val { self.set(ctx, opt, txn, RID.as_ref(), val.clone().into()).await
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!(),
}
} }
} }