Skip to content

v0.5.1

Choose a tag to compare

@apstndb apstndb released this 04 Jun 22:03
78cbef1

Patch release since v0.5.0. Adds opt-in literal quoting configuration and a new protofmt package; preset defaults and runtime output for existing call sites are unchanged unless you opt in.


Highlights

Literal preset — configurable string/bytes quoting (#143 / #150)

  • FormatConfig.Literal.Quote (LiteralQuoteConfig) with strategies QuoteLegacy, QuoteAlways, and QuoteMinEscape, plus PreferredQuote (single/double).
  • Zero value unchanged: LiteralFormatConfig(), FormatRowLiteral, FormatColumnLiteral, and default SQLInsertWriter output match v0.5.0 unless you use a new constructor.
  • New constructors: LiteralFormatConfigWithQuote, LiteralFormatConfigWithSingleQuotedLiterals, LiteralFormatConfigWithOptions, WithLiteralQuote.
  • QuoteLegacy + PreferredSingleQuote: adaptive single-quoted DATE/TIMESTAMP-style literals; use QuoteAlways + PreferredSingleQuote (via LiteralFormatConfigWithSingleQuotedLiterals) when every STRING/BYTES literal must stay single-quoted (SQL INSERT style).
  • Fast and slow literal paths both honor quote policy; FormatLiteralValue and FormatProtoAsCast read Literal.Quote.

protofmt — descriptor-aware PROTO/ENUM display (#149 / #151)

  • New protofmt package with opt-in FormatProtoTextValue and FormatEnumNameValue plugins.
  • Decode Spanner base64 wire payloads, resolve descriptors (dynamic sets, protoregistry.GlobalTypes, composed resolvers), emit protobuf text / enum names with numeric fallback.
  • Root presets and defaults remain descriptor-free; wire up plugins on a cloned FormatConfig.

Documentation

  • writer: RowIterator ownership notes for helper APIs (#148).

Upgrading to v0.5.1

From v0.5.0 (not a repeat of the v0.5.0 writer migration)

No runtime breaking changes for callers using preset constructors or LiteralFormatConfig() defaults.

Compile-time only: FormatConfig gains an exported nested field. Unkeyed composite literals may fail to build:

// Before (v0.5.0)
fc := &spanvalue.FormatConfig{NullString: "NULL", FormatNullable: fn}

// After (v0.5.1)
fc := &spanvalue.FormatConfig{
    NullString:     "NULL",
    FormatNullable: fn,
    Literal:        spanvalue.LiteralFormatOptions{}, // zero Quote = legacy
}

LiteralFormatConfig() signature is unchanged.

Single-quoted SQL INSERT (opt-in)

w, err := writer.NewSQLInsertWriter(out, "users",
    writer.WithFormatter(spanvalue.LiteralFormatConfigWithSingleQuotedLiterals()),
)
// DATE '2014-09-27', 'it\'s fine'

NaN/±Inf CAST literals (v0.5.1 compat; planned v0.6)

Non-finite float CAST output uses a temporary exception under QuoteLegacy (single quotes) vs QuoteAlways / QuoteMinEscape (follow PreferredQuote). Planned v0.6: align with ordinary quote policy in one release; document again at that tag.

Performance

BenchmarkFormatPerType/(STRING|BYTES|DATE)/Literal/Direct vs main @ 3831066 (pre-#150): geomean +0.19% sec/op, allocs/op identical (benchstat, n=5).


Full changelog

v0.5.0...v0.5.1