MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Format

Method Format

postgres/parser/sem/tree/datum.go:1698–1720  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

1696
1697// Format implements the NodeFormatter interface.
1698func (d *DArray) Format(ctx *FmtCtx) {
1699 if ctx.HasFlags(fmtPgwireFormat) {
1700 d.pgwireFormat(ctx)
1701 return
1702 }
1703
1704 // If we want to export arrays, we need to ensure that
1705 // the datums within the arrays are formatted with enclosing quotes etc.
1706 if ctx.HasFlags(FmtExport) {
1707 oldFlags := ctx.flags
1708 ctx.flags = oldFlags & ^FmtExport | FmtParsable
1709 defer func() { ctx.flags = oldFlags }()
1710 }
1711
1712 ctx.WriteString("ARRAY[")
1713 comma := ""
1714 for _, v := range d.Array {
1715 ctx.WriteString(comma)
1716 ctx.FormatNode(v)
1717 comma = ","
1718 }
1719 ctx.WriteByte(']')
1720}
1721
1722const maxArrayLength = math.MaxInt32
1723

Callers

nothing calls this directly

Calls 4

pgwireFormatMethod · 0.95
WriteStringMethod · 0.80
FormatNodeMethod · 0.80
HasFlagsMethod · 0.45

Tested by

no test coverage detected