From 2ffa71d5201ffd5deb95ced4253a31b077c014e4 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 10 Aug 2022 17:26:57 +0100 Subject: [PATCH] Ensure aliased field is output when fetching a multi-yield expressions with final alias Closes #28 --- lib/src/sql/field.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/sql/field.rs b/lib/src/sql/field.rs index 7521e58b..4b300673 100644 --- a/lib/src/sql/field.rs +++ b/lib/src/sql/field.rs @@ -116,7 +116,7 @@ impl Fields { for (p, x) in res { match p.last().unwrap().alias() { // 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 None => out.set(ctx, opt, txn, v, x).await?, } @@ -164,7 +164,11 @@ impl Fields { for (p, x) in res { match p.last().unwrap().alias() { // 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 None => out.set(ctx, opt, txn, i, x).await?, }