diff --git a/db/fetch.go b/db/fetch.go index 351cddb2..2c9417f1 100644 --- a/db/fetch.go +++ b/db/fetch.go @@ -92,15 +92,16 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o if len(path) > 0 { switch res := val.(type) { case []interface{}: + val := make([]interface{}, len(res)) for k, v := range res { - switch val := v.(type) { + switch tng := v.(type) { case *sql.Thing: - res[k], _ = e.fetchThing(ctx, val, doc) + val[k], _ = e.fetchThing(ctx, tng, doc) default: - res[k] = v + val[k] = v } } - return res + return val case *sql.Thing: val, _ = e.fetchThing(ctx, res, doc) return val @@ -127,15 +128,16 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o if len(path) > 0 { switch res := val.(type) { case []interface{}: + val := make([]interface{}, len(res)) for k, v := range res { - switch val := v.(type) { + switch tng := v.(type) { case *sql.Thing: - res[k], _ = e.fetchThing(ctx, val, doc) + val[k], _ = e.fetchThing(ctx, tng, doc) default: - res[k] = v + val[k] = v } } - return res + return val case *sql.Thing: val, _ = e.fetchThing(ctx, res, doc) return val diff --git a/db/yield.go b/db/yield.go index c172a2ee..716e7502 100644 --- a/db/yield.go +++ b/db/yield.go @@ -250,7 +250,15 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke switch res := val.(type) { case []interface{}: - val, _ = d.i.e.fetchArray(ctx, res, doc) + val := make([]interface{}, len(res)) + for k, v := range res { + switch tng := v.(type) { + case *sql.Thing: + val[k], _ = d.i.e.fetchThing(ctx, tng, doc) + default: + val[k] = v + } + } out.Set(val, key) case *sql.Thing: val, _ = d.i.e.fetchThing(ctx, res, doc)