Treat $this param as a special case
This commit is contained in:
parent
892fc99527
commit
cf20cd4396
1 changed files with 27 additions and 12 deletions
|
@ -37,18 +37,33 @@ impl Param {
|
||||||
// Find a base variable by name
|
// Find a base variable by name
|
||||||
match self.name.parts.first() {
|
match self.name.parts.first() {
|
||||||
// The first part will be a field
|
// The first part will be a field
|
||||||
Some(Part::Field(v)) => match ctx.value::<Value>(&v.name) {
|
Some(Part::Field(v)) => match &v.name[..] {
|
||||||
// The base variable exists
|
"this" => match doc {
|
||||||
Some(v) => {
|
// The base document exists
|
||||||
// Get the path parts
|
Some(v) => {
|
||||||
let pth: &[Part] = &self.name;
|
// Get the path parts
|
||||||
// Process the paramater value
|
let pth: &[Part] = &self.name;
|
||||||
let res = v.compute(ctx, opt, txn, doc).await?;
|
// Process the paramater value
|
||||||
// Return the desired field
|
let res = v.compute(ctx, opt, txn, doc).await?;
|
||||||
res.get(ctx, opt, txn, pth.next()).await
|
// Return the desired field
|
||||||
}
|
res.get(ctx, opt, txn, pth.next()).await
|
||||||
// The base variable does not exist
|
}
|
||||||
None => Ok(Value::None),
|
// The base document does not exist
|
||||||
|
None => Ok(Value::None),
|
||||||
|
},
|
||||||
|
_ => match ctx.value::<Value>(&v.name) {
|
||||||
|
// The base variable exists
|
||||||
|
Some(v) => {
|
||||||
|
// Get the path parts
|
||||||
|
let pth: &[Part] = &self.name;
|
||||||
|
// Process the paramater value
|
||||||
|
let res = v.compute(ctx, opt, txn, doc).await?;
|
||||||
|
// Return the desired field
|
||||||
|
res.get(ctx, opt, txn, pth.next()).await
|
||||||
|
}
|
||||||
|
// The base variable does not exist
|
||||||
|
None => Ok(Value::None),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue