v0.6.0
Minor release since v0.5.1. Correctness fixes, safer error handling, writer streaming ergonomics, gcvctor test helpers, and FormatConfig.Validate() for hand-built configs. Preset constructors and typical export paths are unchanged unless noted below.
Highlights
Safer scalar formatting (#152 / #163)
- Nil
FormatNullableon the scalar slow path returnsErrFormatNullableRequiredinstead of panicking. - NULL scalars still use
GetNullString; preset scalar plugins remain active whenFormatNullableis nil.
Literal cast wire validation (#156 / #164)
FormatProtoAsCastandFormatEnumAsCastreject non-stringstructpbwire kinds withErrUnknownTypeinstead of emitting invalid SQL.
Writer correctness and ergonomics
- Zero-column schema guard (#157 / #165): after a registered zero-column row type, non-empty column names return
ErrColumnNamesMismatchinstead of silently overwriting schema. - Empty SQL INSERT table at construction (#147 / #166):
NewSQLInsertWriterreturnsErrEmptyTableNamewhenstrings.TrimSpace(table) == "". Qualified names with empty segments (e.g.db..users) still fail on first write. WithFlushEachRow(#153 / #167): opt-in per-row flush forDelimitedWriter/ CSV streaming without concrete-type assertions.
FormatConfig.Validate() (#158 / #173)
- New
Validate()for hand-built configs: checks required array/struct callbacks,NullString, and complex plugins. Preset constructors are unchanged (they do not callValidate()).
gcvctor test helpers and examples (#161 / #162, #160 / #172)
MustArrayValueOf,MustStructValueOf,MustNormalizeArrayElements, and validated-stringMust*helpers (test-only; panic on error).- pkg.go.dev examples: empty vs NULL arrays, STRUCT container NULLs,
FromPtrvsFromNullable.
Documentation (#155)
protofmtusage recipe andwriterRowIterator hook adapter pattern.
Upgrading to v0.6.0
From v0.5.1
Compile-time: no signature removals. New symbols are additive (Validate, Must*, WithFlushEachRow, ErrFormatNullableRequired).
Runtime behavior changes (review if you use these patterns):
| Area | v0.5.1 | v0.6.0 |
|---|---|---|
NewSQLInsertWriter(out, "") |
Succeeded; failed on first write | Returns ErrEmptyTableName at construction |
Hand-built FormatConfig without FormatNullable on scalar slow path |
Panic | ErrFormatNullableRequired |
| PROTO/ENUM cast with wrong wire kind | Could emit invalid SQL | ErrUnknownType |
| Zero-column schema then non-empty column names | Silent schema overwrite | ErrColumnNamesMismatch |
Preset-backed helpers (LiteralFormatConfig, SimpleFormatConfig, FormatRowLiteral, default SQLInsertWriter with non-empty table) are unaffected.
Delimited streaming without type assertions
w, err := writer.NewCSVWriter(out, writer.WithFlushEachRow())Hand-built FormatConfig
fc := &spanvalue.FormatConfig{ /* ... */ }
if err := fc.Validate(); err != nil { /* ... */ }