diff --git a/db/create.go b/db/create.go index edfab5b6..fa6db0ae 100644 --- a/db/create.go +++ b/db/create.go @@ -96,11 +96,12 @@ func (e *executor) fetchCreate(ctx context.Context, stm *sql.CreateStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars) diff --git a/db/delete.go b/db/delete.go index 8327b12e..86862ff4 100644 --- a/db/delete.go +++ b/db/delete.go @@ -95,11 +95,12 @@ func (e *executor) fetchDelete(ctx context.Context, stm *sql.DeleteStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars) diff --git a/db/insert.go b/db/insert.go index 894e56fc..d2709d6e 100644 --- a/db/insert.go +++ b/db/insert.go @@ -64,11 +64,12 @@ func (e *executor) fetchInsert(ctx context.Context, stm *sql.InsertStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars) diff --git a/db/relate.go b/db/relate.go index 96566cd5..88c72220 100644 --- a/db/relate.go +++ b/db/relate.go @@ -88,11 +88,12 @@ func (e *executor) fetchRelate(ctx context.Context, stm *sql.RelateStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars) diff --git a/db/select.go b/db/select.go index 8f4a1024..1bd9ad0d 100644 --- a/db/select.go +++ b/db/select.go @@ -96,11 +96,12 @@ func (e *executor) fetchSelect(ctx context.Context, stm *sql.SelectStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars) diff --git a/db/update.go b/db/update.go index c168cc6b..04d5d635 100644 --- a/db/update.go +++ b/db/update.go @@ -95,11 +95,12 @@ func (e *executor) fetchUpdate(ctx context.Context, stm *sql.UpdateStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars) diff --git a/db/upsert.go b/db/upsert.go index c5a1ab0c..638b878d 100644 --- a/db/upsert.go +++ b/db/upsert.go @@ -64,11 +64,12 @@ func (e *executor) fetchUpsert(ctx context.Context, stm *sql.UpsertStatement, do if doc != nil { vars := data.New() vars.Set(doc.Data(), varKeyParent) - vars.Array(varKeyParents) if subs := ctx.Value(ctxKeySubs); subs != nil { if subs, ok := subs.(*data.Doc); ok { - vars.Append(subs.Get(varKeyParents).Data(), varKeyParents) + vars.Set(subs.Get(varKeyParents).Data(), varKeyParents) } + } else { + vars.Array(varKeyParents) } vars.Append(doc.Data(), varKeyParents) ctx = context.WithValue(ctx, ctxKeySubs, vars)