Skip to content

Commit 071aef7

Browse files
committed
Minor cleanups
1 parent c14995b commit 071aef7

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

spanner/spanner_snippets/spanner/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func TestSample(t *testing.T) {
439439
out = runSample(t, directedReadOptions, dbName, "failed to read using directed read options")
440440
assertContains(t, out, "1 1 Total Junk")
441441

442-
out = runSample(t, rwTxnExcludedFromChangeStreams, dbName, "failed to commit rw txn excluded from change streams")
442+
out = runSample(t, readWriteTxnExcludedFromChangeStreams, dbName, "failed to commit rw txn excluded from change streams")
443443
assertContains(t, out, "New singer inserted.")
444444
assertContains(t, out, "Singer first name updated.")
445445
}

spanner/spanner_snippets/spanner/spanner_change_streams_txn_exclusion.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -24,13 +24,15 @@ import (
2424
"cloud.google.com/go/spanner"
2525
)
2626

27-
// rwTxnExcludedFromChangeStreams executes the insert and update DMLs on Singers table excluded from allowed tracking change streams
28-
func rwTxnExcludedFromChangeStreams(w io.Writer, db string) error {
27+
// readWriteTxnExcludedFromChangeStreams executes the insert and update DMLs on
28+
// Singers table excluded from tracking change streams with ddl option
29+
// allow_txn_exclusion = true.
30+
func readWriteTxnExcludedFromChangeStreams(w io.Writer, db string) error {
2931
// db = `projects/<project>/instances/<instance-id>/database/<database-id>`
3032
ctx := context.Background()
3133
client, err := spanner.NewClient(ctx, db)
3234
if err != nil {
33-
return fmt.Errorf("rwTxnExcludedFromChangeStreams.NewClient: %w", err)
35+
return fmt.Errorf("readWriteTxnExcludedFromChangeStreams.NewClient: %w", err)
3436
}
3537
defer client.Close()
3638

@@ -41,15 +43,15 @@ func rwTxnExcludedFromChangeStreams(w io.Writer, db string) error {
4143
}
4244
_, err := txn.Update(ctx, stmt)
4345
if err != nil {
44-
return fmt.Errorf("rwTxnExcludedFromChangeStreams.Update: %w", err)
46+
return fmt.Errorf("readWriteTxnExcludedFromChangeStreams.Update: %w", err)
4547
}
46-
fmt.Fprintf(w, "New singer inserted.")
48+
fmt.Fprintln(w, "New singer inserted.")
4749
stmt = spanner.Statement{
4850
SQL: `UPDATE Singers SET FirstName = 'Hi' WHERE SingerId = 111`,
4951
}
5052
_, err = txn.Update(ctx, stmt)
5153
if err != nil {
52-
return fmt.Errorf("rwTxnExcludedFromChangeStreams.Update: %w", err)
54+
return fmt.Errorf("readWriteTxnExcludedFromChangeStreams.Update: %w", err)
5355
}
5456
fmt.Fprint(w, "Singer first name updated.")
5557
return nil

0 commit comments

Comments
 (0)