Check the context before processing values

This commit is contained in:
Tobie Morgan Hitchcock 2022-02-25 22:42:14 +00:00
parent 50e026f859
commit 10c0b5c732
2 changed files with 32 additions and 24 deletions

View file

@ -21,12 +21,14 @@ impl Value {
txn: Transaction, txn: Transaction,
chn: UnboundedSender<(Option<Thing>, Value)>, chn: UnboundedSender<(Option<Thing>, Value)>,
) -> Result<(), Error> { ) -> Result<(), Error> {
match self { if ctx.is_ok() {
Value::Array(v) => v.process(&ctx, &opt, &txn, &chn).await?, match self {
Value::Model(v) => v.process(&ctx, &opt, &txn, &chn).await?, Value::Array(v) => v.process(&ctx, &opt, &txn, &chn).await?,
Value::Thing(v) => v.process(&ctx, &opt, &txn, &chn).await?, Value::Model(v) => v.process(&ctx, &opt, &txn, &chn).await?,
Value::Table(v) => v.process(&ctx, &opt, &txn, &chn).await?, Value::Thing(v) => v.process(&ctx, &opt, &txn, &chn).await?,
v => chn.send((None, v))?, Value::Table(v) => v.process(&ctx, &opt, &txn, &chn).await?,
v => chn.send((None, v))?,
}
} }
Ok(()) Ok(())
} }
@ -42,12 +44,14 @@ impl Array {
chn: &UnboundedSender<(Option<Thing>, Value)>, chn: &UnboundedSender<(Option<Thing>, Value)>,
) -> Result<(), Error> { ) -> Result<(), Error> {
for v in self.value.into_iter() { for v in self.value.into_iter() {
match v { if ctx.is_ok() {
Value::Array(v) => v.process(ctx, opt, txn, chn).await?, match v {
Value::Model(v) => v.process(ctx, opt, txn, chn).await?, Value::Array(v) => v.process(ctx, opt, txn, chn).await?,
Value::Thing(v) => v.process(ctx, opt, txn, chn).await?, Value::Model(v) => v.process(ctx, opt, txn, chn).await?,
Value::Table(v) => v.process(ctx, opt, txn, chn).await?, Value::Thing(v) => v.process(ctx, opt, txn, chn).await?,
v => chn.send((None, v))?, Value::Table(v) => v.process(ctx, opt, txn, chn).await?,
v => chn.send((None, v))?,
}
} }
} }
Ok(()) Ok(())

View file

@ -23,12 +23,14 @@ impl Value {
txn: &Transaction, txn: &Transaction,
ite: &mut Iterator<'_>, ite: &mut Iterator<'_>,
) -> Result<(), Error> { ) -> Result<(), Error> {
match self { if ctx.is_ok() {
Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?, match self {
Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?,
Value::Thing(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?,
Value::Table(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Thing(v) => v.iterate(ctx, opt, txn, ite).await?,
v => ite.process(ctx, opt, txn, None, v).await, Value::Table(v) => v.iterate(ctx, opt, txn, ite).await?,
v => ite.process(ctx, opt, txn, None, v).await,
}
} }
Ok(()) Ok(())
} }
@ -45,12 +47,14 @@ impl Array {
ite: &mut Iterator<'_>, ite: &mut Iterator<'_>,
) -> Result<(), Error> { ) -> Result<(), Error> {
for v in self.value.into_iter() { for v in self.value.into_iter() {
match v { if ctx.is_ok() {
Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?, match v {
Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Array(v) => v.iterate(ctx, opt, txn, ite).await?,
Value::Thing(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Model(v) => v.iterate(ctx, opt, txn, ite).await?,
Value::Table(v) => v.iterate(ctx, opt, txn, ite).await?, Value::Thing(v) => v.iterate(ctx, opt, txn, ite).await?,
v => ite.process(ctx, opt, txn, None, v).await, Value::Table(v) => v.iterate(ctx, opt, txn, ite).await?,
v => ite.process(ctx, opt, txn, None, v).await,
}
} }
} }
Ok(()) Ok(())