Ensure aliased field is output when fetching a multi-yield expressions with final alias

Closes #28
This commit is contained in:
Tobie Morgan Hitchcock 2022-08-10 17:26:57 +01:00
parent 20a6ed88d3
commit 2ffa71d520

View file

@ -116,7 +116,7 @@ impl Fields {
for (p, x) in res { for (p, x) in res {
match p.last().unwrap().alias() { match p.last().unwrap().alias() {
// This is an alias expression part // This is an alias expression part
Some(i) => out.set(ctx, opt, txn, i, x).await?, Some(a) => out.set(ctx, opt, txn, a, x).await?,
// This is the end of the expression // This is the end of the expression
None => out.set(ctx, opt, txn, v, x).await?, None => out.set(ctx, opt, txn, v, x).await?,
} }
@ -164,7 +164,11 @@ impl Fields {
for (p, x) in res { for (p, x) in res {
match p.last().unwrap().alias() { match p.last().unwrap().alias() {
// This is an alias expression part // This is an alias expression part
Some(i) => out.set(ctx, opt, txn, i, x).await?, Some(a) => {
let v = x.clone();
out.set(ctx, opt, txn, a, x).await?;
out.set(ctx, opt, txn, i, v).await?;
}
// This is the end of the expression // This is the end of the expression
None => out.set(ctx, opt, txn, i, x).await?, None => out.set(ctx, opt, txn, i, x).await?,
} }