Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit 000a835

Browse files
Merge branch 'master' into remove-old-instances
2 parents 29ad64b + 7946d64 commit 000a835

11 files changed

Lines changed: 35 additions & 59 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"is": "^3.2.1",
6868
"lodash.snakecase": "^4.1.1",
6969
"merge-stream": "^2.0.0",
70-
"p-queue": "^5.0.0",
70+
"p-queue": "^6.0.2",
7171
"protobufjs": "^6.8.6",
7272
"split-array-stream": "^2.0.0",
7373
"stack-trace": "0.0.10",
@@ -76,7 +76,7 @@
7676
},
7777
"devDependencies": {
7878
"@google-cloud/nodejs-repo-tools": "^3.0.0",
79-
"@types/async": "^2.0.50",
79+
"@types/async": "^3.0.0",
8080
"@types/concat-stream": "^1.6.0",
8181
"@types/extend": "^3.0.0",
8282
"@types/is": "0.0.21",

samples/crud.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ async function queryData(instanceId, databaseId, projectId) {
183183
rows.forEach(row => {
184184
const json = row.toJSON();
185185
console.log(
186-
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${
187-
json.AlbumTitle
188-
}`
186+
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${json.AlbumTitle}`
189187
);
190188
});
191189
} catch (err) {
@@ -234,9 +232,7 @@ async function readData(instanceId, databaseId, projectId) {
234232
rows.forEach(row => {
235233
const json = row.toJSON();
236234
console.log(
237-
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${
238-
json.AlbumTitle
239-
}`
235+
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${json.AlbumTitle}`
240236
);
241237
});
242238
} catch (err) {

samples/dml.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,7 @@ async function queryDataWithParameter(instanceId, databaseId, projectId) {
387387
rows.forEach(row => {
388388
const json = row.toJSON();
389389
console.log(
390-
`SingerId: ${json.SingerId}, FirstName: ${json.FirstName}, LastName: ${
391-
json.LastName
392-
}`
390+
`SingerId: ${json.SingerId}, FirstName: ${json.FirstName}, LastName: ${json.LastName}`
393391
);
394392
});
395393
} catch (err) {
@@ -620,9 +618,7 @@ async function updateUsingBatchDml(instanceId, databaseId, projectId) {
620618
const [rowCounts] = await transaction.batchUpdate(dmlStatements);
621619
await transaction.commit();
622620
console.log(
623-
`Successfully executed ${
624-
rowCounts.length
625-
} SQL statements using Batch DML.`
621+
`Successfully executed ${rowCounts.length} SQL statements using Batch DML.`
626622
);
627623
});
628624
} catch (err) {

samples/indexing.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ async function queryDataWithIndex(
151151
? json.MarketingBudget
152152
: null; // This value is nullable
153153
console.log(
154-
`AlbumId: ${json.AlbumId}, AlbumTitle: ${
155-
json.AlbumTitle
156-
}, MarketingBudget: ${marketingBudget}`
154+
`AlbumId: ${json.AlbumId}, AlbumTitle: ${json.AlbumTitle}, MarketingBudget: ${marketingBudget}`
157155
);
158156
});
159157
} catch (err) {

samples/timestamp.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ async function queryTableWithTimestamp(instanceId, databaseId, projectId) {
157157
rows.forEach(row => {
158158
const json = row.toJSON();
159159
console.log(
160-
`SingerId: ${json.SingerId}, VenueId: ${json.VenueId}, EventDate: ${
161-
json.EventDate
162-
}, Revenue: ${json.Revenue}, LastUpdateTime: ${json.LastUpdateTime}`
160+
`SingerId: ${json.SingerId}, VenueId: ${json.VenueId}, EventDate: ${json.EventDate}, Revenue: ${json.Revenue}, LastUpdateTime: ${json.LastUpdateTime}`
163161
);
164162
});
165163
} catch (err) {

samples/transaction.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ function readOnlyTransaction(instanceId, databaseId, projectId) {
5252
qOneRows.forEach(row => {
5353
const json = row.toJSON();
5454
console.log(
55-
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${
56-
json.AlbumTitle
57-
}`
55+
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${json.AlbumTitle}`
5856
);
5957
});
6058

@@ -70,9 +68,7 @@ function readOnlyTransaction(instanceId, databaseId, projectId) {
7068
qTwoRows.forEach(row => {
7169
const json = row.toJSON();
7270
console.log(
73-
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${
74-
json.AlbumTitle
75-
}`
71+
`SingerId: ${json.SingerId}, AlbumId: ${json.AlbumId}, AlbumTitle: ${json.AlbumTitle}`
7672
);
7773
});
7874

src/database.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -938,18 +938,16 @@ class Database extends ServiceObject {
938938

939939
const snapshot = session.snapshot(options);
940940

941-
snapshot.begin(
942-
(err: null | Error): void => {
943-
if (err) {
944-
this.pool_.release(session);
945-
callback(err);
946-
return;
947-
}
948-
949-
this._releaseOnEnd(session, snapshot);
950-
callback(err, snapshot);
941+
snapshot.begin((err: null | Error): void => {
942+
if (err) {
943+
this.pool_.release(session);
944+
callback(err);
945+
return;
951946
}
952-
);
947+
948+
this._releaseOnEnd(session, snapshot);
949+
callback(err, snapshot);
950+
});
953951
});
954952
}
955953

src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,7 @@ class Spanner extends Service {
384384
delete reqOpts.instance.nodes;
385385
}
386386
if (config.config && config.config.indexOf('/') === -1) {
387-
reqOpts.instance.config = `projects/${this.projectId}/instanceConfigs/${
388-
config.config
389-
}`;
387+
reqOpts.instance.config = `projects/${this.projectId}/instanceConfigs/${config.config}`;
390388
}
391389
this.request(
392390
{

src/session-pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import {EventEmitter} from 'events';
1818
import * as is from 'is';
19-
import * as PQueue from 'p-queue';
19+
import PQueue from 'p-queue';
2020
import trace = require('stack-trace');
2121

2222
import {Database} from './database';

system-test/spanner.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import * as uuid from 'uuid';
2424
import {Spanner} from '../src';
2525

2626
const PREFIX = 'gcloud-tests-';
27-
const RUN_ID = uuid
28-
.v1()
29-
.split('-')
30-
.shift(); // get a short uuid
27+
const RUN_ID = shortUUID();
3128
const LABEL = `gcloud-tests-${RUN_ID}`;
3229
const spanner = new Spanner({projectId: process.env.GCLOUD_PROJECT});
3330

@@ -1236,10 +1233,10 @@ describe('Spanner', () => {
12361233
});
12371234

12381235
it('should insert and query multiple rows', done => {
1239-
const id1 = generateName('id');
1236+
const id1 = generateName('id1');
12401237
const name1 = generateName('name');
12411238

1242-
const id2 = generateName('id');
1239+
const id2 = generateName('id2');
12431240
const name2 = generateName('name');
12441241

12451242
table.insert(
@@ -3196,10 +3193,10 @@ describe('Spanner', () => {
31963193
});
31973194

31983195
it('should insert and query multiple rows', done => {
3199-
const id1 = generateName('id');
3196+
const id1 = generateName('id1');
32003197
const name1 = generateName('name');
32013198

3202-
const id2 = generateName('id');
3199+
const id2 = generateName('id2');
32033200
const name2 = generateName('name');
32043201

32053202
table.insert(
@@ -4353,16 +4350,15 @@ describe('Spanner', () => {
43534350
});
43544351
});
43554352

4353+
function shortUUID() {
4354+
return uuid
4355+
.v4()
4356+
.split('-')
4357+
.shift();
4358+
}
4359+
43564360
function generateName(resourceType) {
4357-
return (
4358-
PREFIX +
4359-
resourceType +
4360-
'-' +
4361-
uuid
4362-
.v1()
4363-
.split('-')
4364-
.shift()
4365-
);
4361+
return PREFIX + resourceType + '-' + shortUUID();
43664362
}
43674363

43684364
function onPromiseOperationComplete(data) {

0 commit comments

Comments
 (0)