v0.5.1
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 strategiesQuoteLegacy,QuoteAlways, andQuoteMinEscape, plusPreferredQuote(single/double).- Zero value unchanged:
LiteralFormatConfig(),FormatRowLiteral,FormatColumnLiteral, and defaultSQLInsertWriteroutput 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; useQuoteAlways + PreferredSingleQuote(viaLiteralFormatConfigWithSingleQuotedLiterals) when every STRING/BYTES literal must stay single-quoted (SQL INSERT style).- Fast and slow literal paths both honor quote policy;
FormatLiteralValueandFormatProtoAsCastreadLiteral.Quote.
protofmt — descriptor-aware PROTO/ENUM display (#149 / #151)
- New
protofmtpackage with opt-inFormatProtoTextValueandFormatEnumNameValueplugins. - 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).