From ba40fd728549964cf264057c0c37d9560823310d Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 31 May 2018 14:34:39 +0100 Subject: [PATCH] Enable $this parameter in SELECT queries It is now possible to select yielded output fields in the same query, without needing to use a subquery. --- db/yield.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/db/yield.go b/db/yield.go index 963cb794..c6e114f9 100644 --- a/db/yield.go +++ b/db/yield.go @@ -184,6 +184,14 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke } } + // Ensure that all output fields are + // available in subsequent expressions + // using the $this parameter. + + vars := data.New() + vars.Set(out.Data(), varKeyThis) + ctx = context.WithValue(ctx, ctxKeySpec, vars) + // Next let's see the field expressions // which have been requested, and add // these to the output document.