Skip to content

v0.3.0

Choose a tag to compare

@apstndb apstndb released this 10 Jun 19:42
3afd801

Stable release consolidating v0.3.0-alpha.1 and v0.3.0-alpha.2 plus documentation work. Mirrored semantics track cloud.google.com/go/spanner v1.91.0.

Added since v0.2.0

  • Column masks for the plain-Go-value helpers (ColumnMaskOption): WithColumns(...) (include) / WithoutColumns(...) (exclude) on MutationColumnsAndValues, MutationMap, and ParamsMap. Masked output keeps struct declaration order; unknown columns, read-only columns in a write-shaped include list, or combining both kinds return the new ErrInvalidColumnMask.
  • WithLossOfPrecisionHandling(spanner.NumericError | spanner.NumericRound) (EncodeOption): per-call NUMERIC loss-of-precision control reusing the client's enum. The client's package-global is never read; the default here is spanner.NumericError (validate → ErrNumericOutOfRange), while the client's global defaults to NumericRound.
  • ParamsMap: struct → map[string]any for spanner.Statement Params (no GCV conversion; read-only fields included, since they are ordinary bindable values).
  • ResultSetMetadataFor[T] / ResultSetMetadataFromGoType: RowTypeFor wrapped in *sppb.ResultSetMetadata for writer metadata and client-side virtual result sets.
  • RowEncoder[T] (NewRowEncoder): compiled row codec — field listing, column mask, and row type resolved once; per row only Values(v, encodeOpts...) runs. Columns() / RowType() / ResultSetMetadata() are mask-aware; agreement with StructColumnsAndValues is pinned by tests.

Documentation

  • Package-doc Adoption guide (readable from go doc / pkg.go.dev): when GCV-based rows pay off vs plain string rows; Columns() vs ResultSetMetadata(); formatting stability across spanvalue upgrades; cross-links to spanvalue.FormatRowColumns so adopters need no per-app GCV→string bridge. Driven by spanner-mycli PoC feedback (#1).
  • ExampleStructColumns_tagOptions pins the tag-option quirk (row-shaped helpers parse ; options; STRUCT-typed values keep the client's raw-tag behavior).
  • Corrected an earlier doc claim: the client's global loss-of-precision default is NumericRound, not NumericError.

Design notes

Two decisions from review are deliberate API shape: option types stay split (EncodeOption vs ColumnMaskOption) so applicability is fixed at compile time, and ParamsMap / MutationMap remain separate functions because read-only handling is determined by the destination (Params vs mutations).

Requirements

  • github.com/apstndb/spanvalue v0.7.1+ (gcvctor UTC-timestamp wire format). Formatting of GCVs is owned by spanvalue, so upgrading it alongside spanenc can change rendered output (for example FLOAT64 display); review those golden-test diffs separately from the spanenc adoption.
  • github.com/apstndb/structfields v0.1.0 / structfields/spannertag v0.1.0.
  • cloud.google.com/go/spanner: go.mod declares only the v1.84.1 MVS floor (mirrored semantics track v1.91.0); your module controls the actual client version.