Don’t reorder array items when fetching records
This commit is contained in:
parent
f8beab1e17
commit
d3fea6365f
2 changed files with 19 additions and 9 deletions
18
db/fetch.go
18
db/fetch.go
|
@ -92,15 +92,16 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
if len(path) > 0 {
|
if len(path) > 0 {
|
||||||
switch res := val.(type) {
|
switch res := val.(type) {
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
|
val := make([]interface{}, len(res))
|
||||||
for k, v := range res {
|
for k, v := range res {
|
||||||
switch val := v.(type) {
|
switch tng := v.(type) {
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
res[k], _ = e.fetchThing(ctx, val, doc)
|
val[k], _ = e.fetchThing(ctx, tng, doc)
|
||||||
default:
|
default:
|
||||||
res[k] = v
|
val[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return val
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
val, _ = e.fetchThing(ctx, res, doc)
|
val, _ = e.fetchThing(ctx, res, doc)
|
||||||
return val
|
return val
|
||||||
|
@ -127,15 +128,16 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
||||||
if len(path) > 0 {
|
if len(path) > 0 {
|
||||||
switch res := val.(type) {
|
switch res := val.(type) {
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
|
val := make([]interface{}, len(res))
|
||||||
for k, v := range res {
|
for k, v := range res {
|
||||||
switch val := v.(type) {
|
switch tng := v.(type) {
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
res[k], _ = e.fetchThing(ctx, val, doc)
|
val[k], _ = e.fetchThing(ctx, tng, doc)
|
||||||
default:
|
default:
|
||||||
res[k] = v
|
val[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return val
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
val, _ = e.fetchThing(ctx, res, doc)
|
val, _ = e.fetchThing(ctx, res, doc)
|
||||||
return val
|
return val
|
||||||
|
|
10
db/yield.go
10
db/yield.go
|
@ -250,7 +250,15 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke
|
||||||
|
|
||||||
switch res := val.(type) {
|
switch res := val.(type) {
|
||||||
case []interface{}:
|
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)
|
out.Set(val, key)
|
||||||
case *sql.Thing:
|
case *sql.Thing:
|
||||||
val, _ = d.i.e.fetchThing(ctx, res, doc)
|
val, _ = d.i.e.fetchThing(ctx, res, doc)
|
||||||
|
|
Loading…
Reference in a new issue