MCPcopy Create free account
hub / github.com/bytebase/bytebase / flattenRowValue

Function flattenRowValue

backend/api/mcp/tool_query.go:259–270  ·  view source on GitHub ↗

flattenRowValue extracts a plain Go value from a protojson RowValue oneof. Each value is a JSON object with exactly one key like {"stringValue": "x"}.

(raw json.RawMessage)

Source from the content-addressed store, hash-verified

257// flattenRowValue extracts a plain Go value from a protojson RowValue oneof.
258// Each value is a JSON object with exactly one key like {"stringValue": "x"}.
259func flattenRowValue(raw json.RawMessage) any {
260 var m map[string]json.RawMessage
261 if json.Unmarshal(raw, &m) != nil {
262 return string(raw)
263 }
264 for key, val := range m {
265 if v, ok := unmarshalRowField(key, val); ok {
266 return v
267 }
268 }
269 return string(raw)
270}
271
272// unmarshalRowField decodes a single protojson RowValue oneof field.
273func unmarshalRowField(key string, val json.RawMessage) (any, bool) {

Callers 1

executeQueryMethod · 0.85

Calls 2

unmarshalRowFieldFunction · 0.85
UnmarshalMethod · 0.80

Tested by

no test coverage detected