MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Format

Method Format

pkg/sql/sem/tree/datum.go:4243–4254  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

4241
4242// Format implements the NodeFormatter interface.
4243func (d *DJSON) Format(ctx *FmtCtx) {
4244 // TODO(justin): ideally the JSON string encoder should know it needs to
4245 // escape things to be inside SQL strings in order to avoid this allocation.
4246 s := d.JSON.String()
4247 if ctx.HasFlags(fmtRawStrings) || ctx.HasFlags(fmtPgwireFormat) {
4248 ctx.WriteString(s)
4249 } else {
4250 // TODO(knz): This seems incorrect,
4251 // see https://github.com/cockroachdb/cockroachdb-parser/issues/60673
4252 lexbase.EncodeSQLStringWithFlags(&ctx.Buffer, s, ctx.flags.EncodeFlags())
4253 }
4254}
4255
4256// Size implements the Datum interface.
4257// TODO(justin): is this a frequently-called method? Should we be caching the computed size?

Callers

nothing calls this directly

Calls 4

EncodeSQLStringWithFlagsFunction · 0.92
EncodeFlagsMethod · 0.80
StringMethod · 0.65
HasFlagsMethod · 0.45

Tested by

no test coverage detected