Skip to content

v0.6.0

Choose a tag to compare

@apstndb apstndb released this 08 Jun 16:25
2bd3ab0

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 FormatNullable on the scalar slow path returns ErrFormatNullableRequired instead of panicking.
  • NULL scalars still use GetNullString; preset scalar plugins remain active when FormatNullable is nil.

Literal cast wire validation (#156 / #164)

  • FormatProtoAsCast and FormatEnumAsCast reject non-string structpb wire kinds with ErrUnknownType instead 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 ErrColumnNamesMismatch instead of silently overwriting schema.
  • Empty SQL INSERT table at construction (#147 / #166): NewSQLInsertWriter returns ErrEmptyTableName when strings.TrimSpace(table) == "". Qualified names with empty segments (e.g. db..users) still fail on first write.
  • WithFlushEachRow (#153 / #167): opt-in per-row flush for DelimitedWriter / 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 call Validate()).

gcvctor test helpers and examples (#161 / #162, #160 / #172)

  • MustArrayValueOf, MustStructValueOf, MustNormalizeArrayElements, and validated-string Must* helpers (test-only; panic on error).
  • pkg.go.dev examples: empty vs NULL arrays, STRUCT container NULLs, FromPtr vs FromNullable.

Documentation (#155)

  • protofmt usage recipe and writer RowIterator 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 { /* ... */ }

Full changelog

v0.5.1...v0.6.0