Enable special param values which supersede subquery params
This commit is contained in:
parent
5357c93558
commit
fd35a134ca
4 changed files with 20 additions and 32 deletions
|
@ -194,7 +194,7 @@ func (d *document) event(ctx context.Context, when method) (err error) {
|
|||
vars.Set(d.id, varKeyThis)
|
||||
vars.Set(d.current.Data(), varKeyAfter)
|
||||
vars.Set(d.initial.Data(), varKeyBefore)
|
||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||
ctx = context.WithValue(ctx, ctxKeySpec, vars)
|
||||
|
||||
for _, ev := range evs {
|
||||
|
||||
|
|
44
db/fetch.go
44
db/fetch.go
|
@ -90,38 +90,24 @@ func (e *executor) fetch(ctx context.Context, val interface{}, doc *data.Doc) (o
|
|||
|
||||
case *sql.Param:
|
||||
|
||||
if obj, ok := ctx.Value(ctxKeySubs).(*data.Doc); ok {
|
||||
for _, s := range paramSearchKeys {
|
||||
|
||||
obj.Fetch(func(key string, val interface{}) interface{} {
|
||||
switch res := val.(type) {
|
||||
case *sql.Thing:
|
||||
val, _ = e.fetchThing(ctx, res, doc)
|
||||
return val
|
||||
default:
|
||||
return val
|
||||
if obj, ok := ctx.Value(s).(*data.Doc); ok {
|
||||
|
||||
obj.Fetch(func(key string, val interface{}) interface{} {
|
||||
switch res := val.(type) {
|
||||
case *sql.Thing:
|
||||
val, _ = e.fetchThing(ctx, res, doc)
|
||||
return val
|
||||
default:
|
||||
return val
|
||||
}
|
||||
})
|
||||
|
||||
if res := obj.Get(val.ID).Data(); res != nil {
|
||||
return e.fetch(ctx, res, doc)
|
||||
}
|
||||
})
|
||||
|
||||
if res := obj.Get(val.ID).Data(); res != nil {
|
||||
return e.fetch(ctx, res, doc)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if obj, ok := ctx.Value(ctxKeyVars).(*data.Doc); ok {
|
||||
|
||||
obj.Fetch(func(key string, val interface{}) interface{} {
|
||||
switch res := val.(type) {
|
||||
case *sql.Thing:
|
||||
val, _ = e.fetchThing(ctx, res, doc)
|
||||
return val
|
||||
default:
|
||||
return val
|
||||
}
|
||||
})
|
||||
|
||||
if res := obj.Get(val.ID).Data(); res != nil {
|
||||
return e.fetch(ctx, res, doc)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ func (d *document) mrgFld(ctx context.Context) (err error) {
|
|||
vars.Set(val, varKeyValue)
|
||||
vars.Set(val, varKeyAfter)
|
||||
vars.Set(old, varKeyBefore)
|
||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||
ctx = context.WithValue(ctx, ctxKeySpec, vars)
|
||||
|
||||
// We are setting the value of the field
|
||||
|
||||
|
@ -306,7 +306,7 @@ func (d *document) mrgFld(ctx context.Context) (err error) {
|
|||
vars.Set(val, varKeyValue)
|
||||
vars.Set(val, varKeyAfter)
|
||||
vars.Set(old, varKeyBefore)
|
||||
ctx = context.WithValue(ctx, ctxKeySubs, vars)
|
||||
ctx = context.WithValue(ctx, ctxKeySpec, vars)
|
||||
|
||||
// We are checking the value of the field
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ const (
|
|||
ctxKeyDb = "db"
|
||||
ctxKeyVars = "vars"
|
||||
ctxKeySubs = "subs"
|
||||
ctxKeySpec = "spec"
|
||||
ctxKeyAuth = "auth"
|
||||
ctxKeyKind = "kind"
|
||||
ctxKeyScope = "scope"
|
||||
|
@ -63,4 +64,5 @@ var (
|
|||
queryNotExecuted = errors.New("Query not executed")
|
||||
queryIdentFailed = errors.New("Found ident but no doc available")
|
||||
featureNotImplemented = errors.New("Feature is not yet implemented")
|
||||
paramSearchKeys = []string{ctxKeySpec, ctxKeySubs, ctxKeyVars}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue