Prevent circular references when yielding data
This commit is contained in:
parent
8fadbc9f35
commit
5c7378c9c7
8 changed files with 14 additions and 8 deletions
|
@ -258,7 +258,13 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
doc.Set(v, e.Field)
|
|
||||||
|
switch v {
|
||||||
|
case d.current:
|
||||||
|
doc.Set(nil, e.Field)
|
||||||
|
default:
|
||||||
|
doc.Set(v, e.Field)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (e *executor) fetchCreate(ctx context.Context, stm *sql.CreateStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (e *executor) fetchDelete(ctx context.Context, stm *sql.DeleteStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ func (e *executor) fetchInsert(ctx context.Context, stm *sql.InsertStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (e *executor) fetchRelate(ctx context.Context, stm *sql.RelateStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (e *executor) fetchSelect(ctx context.Context, stm *sql.SelectStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (e *executor) fetchUpdate(ctx context.Context, stm *sql.UpdateStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ func (e *executor) fetchUpsert(ctx context.Context, stm *sql.UpsertStatement, do
|
||||||
|
|
||||||
if doc != nil {
|
if doc != nil {
|
||||||
vars := data.New()
|
vars := data.New()
|
||||||
vars.Set(doc, varKeyParent)
|
vars.Set(doc.Data(), varKeyParent)
|
||||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue