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

Method WriteValue

expr/dialect.go:140–175  ·  view source on GitHub ↗
(v value.Value)

Source from the content-addressed store, hash-verified

138 io.WriteString(w, w.Null)
139}
140func (w *defaultDialect) WriteValue(v value.Value) {
141 switch vt := v.(type) {
142 case value.StringValue:
143 w.WriteLiteral(vt.Val())
144 case value.IntValue:
145 w.WriteNumber(vt.ToString())
146 case value.NumberValue:
147 w.WriteNumber(vt.ToString())
148 case value.BoolValue:
149 io.WriteString(w, vt.ToString())
150 case nil, value.NilValue:
151 w.WriteNull()
152 case value.TimeValue:
153 w.WriteLiteral(vt.Val().String())
154 case value.Slice:
155 // If you don't want json, then over-ride this WriteValue
156 by, err := vt.MarshalJSON()
157 if err == nil {
158 w.Write(by)
159 } else {
160 u.Debugf("could not convert %v", err)
161 w.Write([]byte("[]"))
162 }
163 case value.Map:
164 // If you don't want json, then over-ride this WriteValue
165 by, err := vt.MarshalJSON()
166 if err == nil {
167 w.Write(by)
168 } else {
169 u.Debugf("could not convert %v", err)
170 w.Write([]byte("null"))
171 }
172 default:
173 io.WriteString(w, vt.ToString())
174 }
175}
176
177// WriteLiteral writes literal and escapes " with \"
178func (w *jsonDialect) WriteLiteral(l string) {

Callers

nothing calls this directly

Calls 7

WriteLiteralMethod · 0.95
WriteNumberMethod · 0.95
WriteNullMethod · 0.95
ToStringMethod · 0.65
StringMethod · 0.65
ValMethod · 0.45
MarshalJSONMethod · 0.45

Tested by

no test coverage detected