MCPcopy Create free account
hub / github.com/araddon/qlbridge / msgToRow

Function msgToRow

exec/results.go:223–271  ·  view source on GitHub ↗
(msg schema.Message, cols []string, dest []driver.Value)

Source from the content-addressed store, hash-verified

221}
222
223func msgToRow(msg schema.Message, cols []string, dest []driver.Value) error {
224
225 //u.Debugf("msg? %v %T \n%p %v", msg, msg, dest, dest)
226 switch mt := msg.Body().(type) {
227 /*
228 case *datasource.ContextUrlValues:
229 for i, key := range cols {
230 if val, ok := mt.Get(key); ok && !val.Nil() {
231 dest[i] = val.Value()
232 //u.Infof("key=%v val=%v", key, val)
233 } else {
234 u.Warnf("missing value? %v %T %v", key, val.Value(), val.Value())
235 }
236 }
237 //u.Debugf("got msg in row result writer: %#v", mt)
238
239 case *datasource.ContextSimple:
240 for i, key := range cols {
241 //u.Debugf("key=%v mt = nil? %v", key, mt)
242 if val, ok := mt.Get(key); ok && val != nil && !val.Nil() {
243 dest[i] = val.Value()
244 //u.Infof("key=%v val=%v", key, val)
245 } else if val == nil {
246 u.Errorf("could not evaluate? %v %#v", key, mt)
247 } else {
248 u.Warnf("missing value? %v %T %v", key, val.Value(), val.Value())
249 }
250 }
251 //u.Debugf("got msg in row result writer: %#v", dest)
252 */
253 case *datasource.SqlDriverMessageMap:
254 for i, key := range cols {
255 val, ok := mt.Get(key)
256 //u.Debugf("key=%v %T %v", key, val, val)
257 if ok && val != nil && !val.Nil() {
258 dest[i] = val.Value()
259 //u.Infof("key=%v val=%v", key, val)
260 } else if val == nil {
261 u.Errorf("could not evaluate? %v %#v", key, mt)
262 } else {
263 u.Warnf("missing value? %v %T %v", key, val.Value(), val.Value())
264 }
265 }
266 //u.Debugf("got msg in row result writer: %#v", dest)
267 default:
268 u.Errorf("unknown message type: %T", mt)
269 }
270 return nil
271}

Callers 1

NextMethod · 0.85

Calls 5

ErrorfMethod · 0.80
BodyMethod · 0.65
GetMethod · 0.65
NilMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected