Ensure remote record fetching works correctly

This commit is contained in:
Tobie Morgan Hitchcock 2022-02-05 09:24:39 +00:00
parent 40049aefb0
commit f4029e0689

View file

@ -64,7 +64,7 @@ impl Value {
// Current path part is a thing // Current path part is a thing
Value::Thing(v) => match path.parts.len() { Value::Thing(v) => match path.parts.len() {
// No remote embedded fields, so just return this // No remote embedded fields, so just return this
1 => Ok(Value::Thing(v.clone())), 0 => Ok(Value::Thing(v.clone())),
// Remote embedded field, so fetch the thing // Remote embedded field, so fetch the thing
_ => { _ => {
let stm = SelectStatement { let stm = SelectStatement {
@ -72,10 +72,12 @@ impl Value {
what: Values(vec![Value::Thing(v.clone())]), what: Values(vec![Value::Thing(v.clone())]),
..SelectStatement::default() ..SelectStatement::default()
}; };
match stm.compute(ctx, opt, exe, None).await { stm.compute(ctx, opt, exe, None)
Ok(v) => v.get(ctx, opt, exe, &path.next()).await, .await?
Err(_) => Ok(Value::None), .first(ctx, opt, exe)
} .await?
.get(ctx, opt, exe, &path)
.await
} }
}, },
// Ignore everything else // Ignore everything else