diff --git a/db/check.go b/db/check.go index b098f11d..ed6cb7c6 100644 --- a/db/check.go +++ b/db/check.go @@ -258,7 +258,13 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke if err != nil { return nil, err } - doc.Set(v, e.Field) + + switch v { + case d.current: + doc.Set(nil, e.Field) + default: + doc.Set(v, e.Field) + } } diff --git a/db/create.go b/db/create.go index 1bb9543a..ca296d42 100644 --- a/db/create.go +++ b/db/create.go @@ -80,7 +80,7 @@ func (e *executor) fetchCreate(ctx context.Context, stm *sql.CreateStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) } diff --git a/db/delete.go b/db/delete.go index 6ad63d18..afea0258 100644 --- a/db/delete.go +++ b/db/delete.go @@ -79,7 +79,7 @@ func (e *executor) fetchDelete(ctx context.Context, stm *sql.DeleteStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) } diff --git a/db/insert.go b/db/insert.go index 28c1857e..93216538 100644 --- a/db/insert.go +++ b/db/insert.go @@ -58,7 +58,7 @@ func (e *executor) fetchInsert(ctx context.Context, stm *sql.InsertStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) } diff --git a/db/relate.go b/db/relate.go index 9a28e0c4..81fcd7ab 100644 --- a/db/relate.go +++ b/db/relate.go @@ -72,7 +72,7 @@ func (e *executor) fetchRelate(ctx context.Context, stm *sql.RelateStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) } diff --git a/db/select.go b/db/select.go index 118faf0b..918af588 100644 --- a/db/select.go +++ b/db/select.go @@ -86,7 +86,7 @@ func (e *executor) fetchSelect(ctx context.Context, stm *sql.SelectStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) } diff --git a/db/update.go b/db/update.go index ecd93151..be6baf09 100644 --- a/db/update.go +++ b/db/update.go @@ -79,7 +79,7 @@ func (e *executor) fetchUpdate(ctx context.Context, stm *sql.UpdateStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) } diff --git a/db/upsert.go b/db/upsert.go index a29a26b2..7e802178 100644 --- a/db/upsert.go +++ b/db/upsert.go @@ -58,7 +58,7 @@ func (e *executor) fetchUpsert(ctx context.Context, stm *sql.UpsertStatement, do if doc != nil { vars := data.New() - vars.Set(doc, varKeyParent) + vars.Set(doc.Data(), varKeyParent) ctx = context.WithValue(ctx, ctxKeySubs, vars) }