Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 5145 | |
| 5146 | // Format implements the NodeFormatter interface. |
| 5147 | func (d *DArray) Format(ctx *FmtCtx) { |
| 5148 | if ctx.flags.HasAnyFlags(fmtPgwireFormat | fmtPGCatalog) { |
| 5149 | defer func(f FmtFlags) { ctx.flags = f }(ctx.flags) |
| 5150 | ctx.flags = ctx.flags & ^fmtPGCatalogCasts |
| 5151 | ctx.flags = ctx.flags | FmtBareStrings |
| 5152 | d.pgwireFormat(ctx) |
| 5153 | return |
| 5154 | } |
| 5155 | |
| 5156 | // If we want to export arrays, we need to ensure that |
| 5157 | // the datums within the arrays are formatted with enclosing quotes etc. |
| 5158 | if ctx.HasFlags(FmtExport) { |
| 5159 | oldFlags := ctx.flags |
| 5160 | ctx.flags = oldFlags & ^FmtExport | FmtParsable |
| 5161 | defer func() { ctx.flags = oldFlags }() |
| 5162 | } |
| 5163 | |
| 5164 | ctx.WriteString("ARRAY[") |
| 5165 | comma := "" |
| 5166 | for _, v := range d.Array { |
| 5167 | ctx.WriteString(comma) |
| 5168 | ctx.FormatNode(v) |
| 5169 | comma = "," |
| 5170 | } |
| 5171 | ctx.WriteByte(']') |
| 5172 | } |
| 5173 | |
| 5174 | const maxArrayLength = math.MaxInt32 |
| 5175 |
no test coverage detected