From 96afde18ecfefebe2fc37fbfecf58bfb871f4474 Mon Sep 17 00:00:00 2001 From: shuheiktgw Date: Wed, 22 Dec 2021 07:11:58 +0900 Subject: [PATCH] feat(spanner): Add ReadRowWithOptions method --- spanner/transaction.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spanner/transaction.go b/spanner/transaction.go index b9da4f401fe0..4ab2e76a2122 100644 --- a/spanner/transaction.go +++ b/spanner/transaction.go @@ -212,7 +212,15 @@ func errMultipleRowsFound(table string, key Key, index string) error { // If no row is present with the given key, then ReadRow returns an error where // spanner.ErrCode(err) is codes.NotFound. func (t *txReadOnly) ReadRow(ctx context.Context, table string, key Key, columns []string) (*Row, error) { - iter := t.Read(ctx, table, key, columns) + return t.ReadRowWithOptions(ctx, table, key, columns, nil) +} + +// ReadRowWithOptions reads a single row from the database. Pass a ReadOptions to modify the read operation. +// +// If no row is present with the given key, then ReadRowWithOptions returns an error where +// spanner.ErrCode(err) is codes.NotFound. +func (t *txReadOnly) ReadRowWithOptions(ctx context.Context, table string, key Key, columns []string, opts *ReadOptions) (*Row, error) { + iter := t.ReadWithOptions(ctx, table, key, columns, opts) defer iter.Stop() row, err := iter.Next() switch err {