Skip to content

Commit

Permalink
🐛 support null resources
Browse files Browse the repository at this point in the history
  • Loading branch information
arlimus authored and vjeffrey committed Sep 14, 2023
1 parent 6bf16e9 commit da64b1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cli/printer/mql.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ func (print *Printer) autoExpand(blockRef uint64, data interface{}, bundle *llx.
return res.String()
}

if data == nil {
return print.Secondary("null")
}

m, ok := data.(map[string]interface{})
if !ok {
return "data is not a map to auto-expand"
Expand Down
13 changes: 8 additions & 5 deletions providers-sdk/v1/plugin/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,16 @@ func (x *TValue[T]) ToDataRes(typ types.Type) *DataRes {
return &DataRes{}
}
if x.State&StateIsNull != 0 {
res := &DataRes{
Data: &llx.Primitive{Type: string(typ)},
}
if x.Error != nil {
res.Error = x.Error.Error()
return &DataRes{
Error: x.Error.Error(),
Data: &llx.Primitive{Type: string(typ)},
}
}

return &DataRes{
Data: &llx.Primitive{Type: string(types.Nil)},
}
return res
}
raw := llx.RawData{Type: typ, Value: x.Data, Error: x.Error}
res := raw.Result()
Expand Down

0 comments on commit da64b1d

Please sign in to comment.