Ensure remote records in FETCH clauses are fetched correctly
This commit is contained in:
parent
94a9110e06
commit
a687a7f4bf
3 changed files with 15 additions and 2 deletions
|
@ -307,7 +307,7 @@ impl Iterator {
|
||||||
match val {
|
match val {
|
||||||
Value::Array(v) => {
|
Value::Array(v) => {
|
||||||
// Fetch all remote records
|
// Fetch all remote records
|
||||||
let val = Value::Array(v).get(ctx, opt, txn, &[Part::All]).await?;
|
let val = Value::Array(v).get(ctx, opt, txn, &[Part::Any]).await?;
|
||||||
// Set the value at the path
|
// Set the value at the path
|
||||||
obj.set(ctx, opt, txn, fetch, val).await?;
|
obj.set(ctx, opt, txn, fetch, val).await?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ use std::str;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
pub enum Part {
|
pub enum Part {
|
||||||
|
Any,
|
||||||
All,
|
All,
|
||||||
Last,
|
Last,
|
||||||
First,
|
First,
|
||||||
|
@ -103,6 +104,7 @@ impl Part {
|
||||||
impl fmt::Display for Part {
|
impl fmt::Display for Part {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
Part::Any => write!(f, ".."),
|
||||||
Part::All => write!(f, "[*]"),
|
Part::All => write!(f, "[*]"),
|
||||||
Part::Last => write!(f, "[$]"),
|
Part::Last => write!(f, "[$]"),
|
||||||
Part::First => write!(f, "[0]"),
|
Part::First => write!(f, "[0]"),
|
||||||
|
|
|
@ -38,6 +38,7 @@ impl Value {
|
||||||
None => Ok(Value::None),
|
None => Ok(Value::None),
|
||||||
},
|
},
|
||||||
Part::All => self.get(ctx, opt, txn, path.next()).await,
|
Part::All => self.get(ctx, opt, txn, path.next()).await,
|
||||||
|
Part::Any => self.get(ctx, opt, txn, path.next()).await,
|
||||||
_ => Ok(Value::None),
|
_ => Ok(Value::None),
|
||||||
},
|
},
|
||||||
// Current path part is an array
|
// Current path part is an array
|
||||||
|
@ -47,6 +48,10 @@ impl Value {
|
||||||
let futs = v.iter().map(|v| v.get(ctx, opt, txn, path));
|
let futs = v.iter().map(|v| v.get(ctx, opt, txn, path));
|
||||||
try_join_all(futs).await.map(|v| v.into())
|
try_join_all(futs).await.map(|v| v.into())
|
||||||
}
|
}
|
||||||
|
Part::Any => {
|
||||||
|
let futs = v.iter().map(|v| v.get(ctx, opt, txn, path));
|
||||||
|
try_join_all(futs).await.map(|v| v.into())
|
||||||
|
}
|
||||||
Part::First => match v.first() {
|
Part::First => match v.first() {
|
||||||
Some(v) => v.get(ctx, opt, txn, path.next()).await,
|
Some(v) => v.get(ctx, opt, txn, path.next()).await,
|
||||||
None => Ok(Value::None),
|
None => Ok(Value::None),
|
||||||
|
@ -132,7 +137,13 @@ impl Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ignore everything else
|
// Ignore everything else
|
||||||
_ => Ok(Value::None),
|
_ => match p {
|
||||||
|
Part::Any => match path.len() {
|
||||||
|
1 => Ok(self.clone()),
|
||||||
|
_ => Ok(Value::None),
|
||||||
|
},
|
||||||
|
_ => Ok(Value::None),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// No more parts so get the value
|
// No more parts so get the value
|
||||||
None => Ok(self.clone()),
|
None => Ok(self.clone()),
|
||||||
|
|
Loading…
Reference in a new issue