From af5ec5239e1b9f309c50ea6a5a5f859093fb14c8 Mon Sep 17 00:00:00 2001 From: Alka Trivedi Date: Mon, 24 Jun 2024 11:10:42 +0530 Subject: [PATCH 1/2] feat: change stream transaction exclusion option for Batch Write --- src/database.ts | 1 + src/transaction.ts | 1 + test/database.ts | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/database.ts b/src/database.ts index 4e9844cc4..f89b65839 100644 --- a/src/database.ts +++ b/src/database.ts @@ -3289,6 +3289,7 @@ class Database extends common.GrpcServiceObject { session: session!.formattedName_!, mutationGroups: mutationGroups.map(mg => mg.proto()), requestOptions: options?.requestOptions, + excludeTxnFromChangeStream: options?.excludeTxnFromChangeStreams, } ); let dataReceived = false; diff --git a/src/transaction.ts b/src/transaction.ts index d5ec34a30..21817204d 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -62,6 +62,7 @@ export interface TimestampBounds { export interface BatchWriteOptions { requestOptions?: Pick; gaxOptions?: CallOptions; + excludeTxnFromChangeStreams?: boolean; } export interface RequestOptions { diff --git a/test/database.ts b/test/database.ts index 9fb89c14d..6cdec3d3a 100644 --- a/test/database.ts +++ b/test/database.ts @@ -600,6 +600,7 @@ describe('Database', () => { requestOptions: { transactionTag: 'batch-write-tag', }, + excludeTxnFromChangeStream: true, gaxOptions: {autoPaginate: false}, } as BatchWriteOptions; @@ -636,7 +637,7 @@ describe('Database', () => { }); }); - it('should call `requestStream` with correct arguments', () => { + it.only('should call `requestStream` with correct arguments', () => { const expectedGaxOpts = extend(true, {}, options?.gaxOptions); const expectedReqOpts = Object.assign( {} as google.spanner.v1.BatchWriteRequest, @@ -644,6 +645,7 @@ describe('Database', () => { session: fakeSession!.formattedName_!, mutationGroups: mutationGroups.map(mg => mg.proto()), requestOptions: options?.requestOptions, + excludeTxnFromChangeStream: options?.excludeTxnFromChangeStreams, } ); From 4c097295e22e4da25ab1692d52106243d5cda95f Mon Sep 17 00:00:00 2001 From: Alka Trivedi Date: Fri, 5 Jul 2024 15:41:14 +0530 Subject: [PATCH 2/2] refactor --- test/database.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/database.ts b/test/database.ts index 6cdec3d3a..059f704fe 100644 --- a/test/database.ts +++ b/test/database.ts @@ -637,7 +637,7 @@ describe('Database', () => { }); }); - it.only('should call `requestStream` with correct arguments', () => { + it('should call `requestStream` with correct arguments', () => { const expectedGaxOpts = extend(true, {}, options?.gaxOptions); const expectedReqOpts = Object.assign( {} as google.spanner.v1.BatchWriteRequest,