Skip to content

v0.3.1

Choose a tag to compare

@apstndb apstndb released this 11 Jun 04:50
8d2c5ed

Patch release since v0.3.0: additive RowEncoder APIs and internal adoption of spanvalue gcvctor constructors. No breaking changes. Mirrored semantics still track cloud.google.com/go/spanner v1.91.0.

Added

  • RowEncoder.Row(v, encodeOpts...) / RowEncoder.Rows(items, encodeOpts...) (#2): encode structs into real *spanner.Row values so client-side (virtual) result sets flow through the same *spanner.Row pipelines as server query results. Row is Values + spanner.NewRow (the client deep-clones the GCVs without re-encoding, so rows carry exactly the encoder's output including typed NULLs and do not alias encoder state). Rows returns a lazy iter.Seq2[*spanner.Row, error] — each row is encoded only when yielded (pinned by test), and an encode failure yields (nil, err) once and stops. Pairs with writer.RunRowSeq / writer.WriteRowSeq introduced in spanvalue v0.7.4, whose abort-on-yielded-error contract matches by design.
  • MustNewRowEncoder[T]: NewRowEncoder panicking on error, for package-level encoders of compile-time-known struct types — prefer it over local panic-on-error wrappers (surveyed from the spanner-mycli PoC, apstndb/spanner-mycli#657).

Changed (no behavior change)

  • Hand-rolled nullable encoding helpers were replaced with the gcvctor constructors added for spanenc in spanvalue v0.7.2–v0.7.3 (apstndb/spanvalue#232, apstndb/spanvalue#236): IntervalFromNullable, NumericFromNullable (behind the existing NUMERIC validation), PGNumericFromNullable, JSONFromNullable, PGJSONBFromNullable. Client-mirror semantics are unchanged and pinned by tests, including the quoted-JSON-string wire for string-valued NullJSON / PGJsonB (fixed on the spanvalue side in v0.7.3; spanenc deliberately skipped the v0.7.2 helpers whose string special-case diverged from the client).

Documentation

  • Adoption guide: the string-only-row exception now spells out when routing display strings through GCVs is worth it (a single cell pipeline shared with server results, or scaffolding call sites that will gain typed columns) and asks adopters to record that intent in a comment; NULL cells should be detected with spanvalue.IsNull rather than inspecting the protobuf value kind by hand.

Requirements

  • github.com/apstndb/spanvalue v0.7.3+ (gcvctor JSONFromNullable / PGJSONBFromNullable with client-compatible marshal semantics). Streaming RowEncoder.Rows output through writer.WriteRowSeq additionally needs spanvalue v0.7.4+.
  • github.com/apstndb/structfields v0.1.0 / structfields/spannertag v0.1.0 (unchanged).
  • 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.

Full changelog

v0.3.0...v0.3.1