@google-cloud/spanner 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions
6
6
 
7
+ ## [6.5.0](https://github.com/googleapis/nodejs-spanner/compare/v6.4.0...v6.5.0) (2022-11-30)
8
+
9
+
10
+ ### Features
11
+
12
+ * Inline BeginTransaction with first statement ([#1692](https://github.com/googleapis/nodejs-spanner/issues/1692)) ([d1b95d2](https://github.com/googleapis/nodejs-spanner/commit/d1b95d21e2c8cb0eff88351265cad248870bb3ea))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * Cleanup different types of session pools ([#1739](https://github.com/googleapis/nodejs-spanner/issues/1739)) ([6f55187](https://github.com/googleapis/nodejs-spanner/commit/6f551877ea0d4b67e3c734377bdadd5d570cf839))
18
+ * **deps:** Use google-gax v3.5.2 ([#1732](https://github.com/googleapis/nodejs-spanner/issues/1732)) ([8341b1f](https://github.com/googleapis/nodejs-spanner/commit/8341b1fa5dfcf0b286892efb8b57c7ad694cdbb8))
19
+
20
+ ## [6.4.0](https://github.com/googleapis/nodejs-spanner/compare/v6.3.0...v6.4.0) (2022-10-27)
21
+
22
+
23
+ ### Features
24
+
25
+ * Adding support and samples for Jsonb data type in spangres ([#1729](https://github.com/googleapis/nodejs-spanner/issues/1729)) ([f050354](https://github.com/googleapis/nodejs-spanner/commit/f0503547012ab0ac8a04524ecf7bc92807f35379))
26
+ * Update result_set.proto to return undeclared parameters in ExecuteSql API ([eaa445e](https://github.com/googleapis/nodejs-spanner/commit/eaa445ed314190abefc17e3672bb5e200142618b))
27
+ * Update transaction.proto to include different lock modes ([#1723](https://github.com/googleapis/nodejs-spanner/issues/1723)) ([eaa445e](https://github.com/googleapis/nodejs-spanner/commit/eaa445ed314190abefc17e3672bb5e200142618b))
28
+
7
29
  ## [6.3.0](https://github.com/googleapis/nodejs-spanner/compare/v6.2.0...v6.3.0) (2022-10-03)
8
30
 
9
31
 
package/README.md CHANGED
@@ -144,6 +144,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
144
144
  | Calls a server side function on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-functions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-functions.js,samples/README.md) |
145
145
  | Creates a new storing index in a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-index-create-storing.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-index-create-storing.js,samples/README.md) |
146
146
  | Created interleaved table hierarchy using PostgreSQL dialect. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-interleaving.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-interleaving.js,samples/README.md) |
147
+ | Showcase how add a jsonb column in a PostgreSQL table. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-jsonb-add-column.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-jsonb-add-column.js,samples/README.md) |
148
+ | Showcase how query data to a jsonb column in a PostgreSQL table. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-jsonb-query-parameter.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-jsonb-query-parameter.js,samples/README.md) |
149
+ | Showcase how update data to a jsonb column in a PostgreSQL table. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-jsonb-update-data.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-jsonb-update-data.js,samples/README.md) |
147
150
  | Showcase how to work with the PostgreSQL NUMERIC/DECIMAL data type on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-numeric-data-type.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-numeric-data-type.js,samples/README.md) |
148
151
  | Showcases how a Spanner PostgreSQL database orders null values in a query. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-ordering-nulls.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-ordering-nulls.js,samples/README.md) |
149
152
  | Execute a query with parameters on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-query-parameter.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-query-parameter.js,samples/README.md) |
@@ -174,6 +174,18 @@ message ResultSetMetadata {
174
174
  // If the read or SQL query began a transaction as a side-effect, the
175
175
  // information about the new transaction is yielded here.
176
176
  Transaction transaction = 2;
177
+
178
+ // A SQL query can be parameterized. In PLAN mode, these parameters can be
179
+ // undeclared. This indicates the field names and types for those undeclared
180
+ // parameters in the SQL query. For example, a SQL query like `"SELECT * FROM
181
+ // Users where UserId = @userId and UserName = @userName "` could return a
182
+ // `undeclared_parameters` value like:
183
+ //
184
+ // "fields": [
185
+ // { "name": "UserId", "type": { "code": "INT64" } },
186
+ // { "name": "UserName", "type": { "code": "STRING" } },
187
+ // ]
188
+ StructType undeclared_parameters = 3;
177
189
  }
178
190
 
179
191
  // Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or [PartialResultSet][google.spanner.v1.PartialResultSet].
@@ -56,7 +56,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
56
56
  //
57
57
  // Queries on change streams must be performed with the snapshot read-only
58
58
  // transaction mode, specifying a strong read. Please see
59
- // [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong] for more details.
59
+ // [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]
60
+ // for more details.
60
61
  //
61
62
  // 3. Partitioned DML. This type of transaction is used to execute
62
63
  // a single Partitioned DML statement. Partitioned DML partitions
@@ -192,7 +193,8 @@ option ruby_package = "Google::Cloud::Spanner::V1";
192
193
  // Queries on change streams (see below for more details) must also specify
193
194
  // the strong read timestamp bound.
194
195
  //
195
- // See [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
196
+ // See
197
+ // [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
196
198
  //
197
199
  // Exact staleness:
198
200
  //
@@ -213,7 +215,9 @@ option ruby_package = "Google::Cloud::Spanner::V1";
213
215
  // equivalent boundedly stale concurrency modes. On the other hand,
214
216
  // boundedly stale reads usually return fresher results.
215
217
  //
216
- // See [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp] and
218
+ // See
219
+ // [TransactionOptions.ReadOnly.read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp]
220
+ // and
217
221
  // [TransactionOptions.ReadOnly.exact_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness].
218
222
  //
219
223
  // Bounded staleness:
@@ -243,7 +247,9 @@ option ruby_package = "Google::Cloud::Spanner::V1";
243
247
  // which rows will be read, it can only be used with single-use
244
248
  // read-only transactions.
245
249
  //
246
- // See [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness] and
250
+ // See
251
+ // [TransactionOptions.ReadOnly.max_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max_staleness]
252
+ // and
247
253
  // [TransactionOptions.ReadOnly.min_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp].
248
254
  //
249
255
  // Old read timestamps and garbage collection:
@@ -349,14 +355,34 @@ message TransactionOptions {
349
355
  // Message type to initiate a read-write transaction. Currently this
350
356
  // transaction type has no options.
351
357
  message ReadWrite {
358
+ // `ReadLockMode` is used to set the read lock mode for read-write
359
+ // transactions.
360
+ enum ReadLockMode {
361
+ // Default value.
362
+ //
363
+ // If the value is not specified, the pessimistic read lock is used.
364
+ READ_LOCK_MODE_UNSPECIFIED = 0;
352
365
 
353
- }
366
+ // Pessimistic lock mode.
367
+ //
368
+ // Read locks are acquired immediately on read.
369
+ PESSIMISTIC = 1;
354
370
 
355
- // Message type to initiate a Partitioned DML transaction.
356
- message PartitionedDml {
371
+ // Optimistic lock mode.
372
+ //
373
+ // Locks for reads within the transaction are not acquired on read.
374
+ // Instead the locks are acquired on a commit to validate that
375
+ // read/queried data has not changed since the transaction started.
376
+ OPTIMISTIC = 2;
377
+ }
357
378
 
379
+ // Read lock mode for the transaction.
380
+ ReadLockMode read_lock_mode = 1;
358
381
  }
359
382
 
383
+ // Message type to initiate a Partitioned DML transaction.
384
+ message PartitionedDml {}
385
+
360
386
  // Message type to initiate a read-only transaction.
361
387
  message ReadOnly {
362
388
  // How to choose the timestamp for the read-only transaction.
@@ -421,7 +447,8 @@ message TransactionOptions {
421
447
  }
422
448
 
423
449
  // If true, the Cloud Spanner-selected read timestamp is included in
424
- // the [Transaction][google.spanner.v1.Transaction] message that describes the transaction.
450
+ // the [Transaction][google.spanner.v1.Transaction] message that describes
451
+ // the transaction.
425
452
  bool return_read_timestamp = 6;
426
453
  }
427
454
 
@@ -475,7 +502,8 @@ message Transaction {
475
502
  // [Read][google.spanner.v1.Spanner.Read] or
476
503
  // [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
477
504
  //
478
- // See [TransactionOptions][google.spanner.v1.TransactionOptions] for more information about transactions.
505
+ // See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
506
+ // information about transactions.
479
507
  message TransactionSelector {
480
508
  // If no fields are set, the default is a single use transaction
481
509
  // with strong concurrency.
@@ -490,7 +518,8 @@ message TransactionSelector {
490
518
 
491
519
  // Begin a new transaction and execute this read or SQL query in
492
520
  // it. The transaction ID of the new transaction is returned in
493
- // [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction], which is a [Transaction][google.spanner.v1.Transaction].
521
+ // [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
522
+ // which is a [Transaction][google.spanner.v1.Transaction].
494
523
  TransactionOptions begin = 3;
495
524
  }
496
525
  }
@@ -14846,6 +14846,9 @@ export namespace google {
14846
14846
 
14847
14847
  /** ResultSetMetadata transaction */
14848
14848
  transaction?: (google.spanner.v1.ITransaction|null);
14849
+
14850
+ /** ResultSetMetadata undeclaredParameters */
14851
+ undeclaredParameters?: (google.spanner.v1.IStructType|null);
14849
14852
  }
14850
14853
 
14851
14854
  /** Represents a ResultSetMetadata. */
@@ -14863,6 +14866,9 @@ export namespace google {
14863
14866
  /** ResultSetMetadata transaction. */
14864
14867
  public transaction?: (google.spanner.v1.ITransaction|null);
14865
14868
 
14869
+ /** ResultSetMetadata undeclaredParameters. */
14870
+ public undeclaredParameters?: (google.spanner.v1.IStructType|null);
14871
+
14866
14872
  /**
14867
14873
  * Creates a new ResultSetMetadata instance using the specified properties.
14868
14874
  * @param [properties] Properties to set
@@ -15175,6 +15181,9 @@ export namespace google {
15175
15181
 
15176
15182
  /** Properties of a ReadWrite. */
15177
15183
  interface IReadWrite {
15184
+
15185
+ /** ReadWrite readLockMode */
15186
+ readLockMode?: (google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode|keyof typeof google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode|null);
15178
15187
  }
15179
15188
 
15180
15189
  /** Represents a ReadWrite. */
@@ -15186,6 +15195,9 @@ export namespace google {
15186
15195
  */
15187
15196
  constructor(properties?: google.spanner.v1.TransactionOptions.IReadWrite);
15188
15197
 
15198
+ /** ReadWrite readLockMode. */
15199
+ public readLockMode: (google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode|keyof typeof google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode);
15200
+
15189
15201
  /**
15190
15202
  * Creates a new ReadWrite instance using the specified properties.
15191
15203
  * @param [properties] Properties to set
@@ -15264,6 +15276,16 @@ export namespace google {
15264
15276
  public static getTypeUrl(typeUrlPrefix?: string): string;
15265
15277
  }
15266
15278
 
15279
+ namespace ReadWrite {
15280
+
15281
+ /** ReadLockMode enum. */
15282
+ enum ReadLockMode {
15283
+ READ_LOCK_MODE_UNSPECIFIED = 0,
15284
+ PESSIMISTIC = 1,
15285
+ OPTIMISTIC = 2
15286
+ }
15287
+ }
15288
+
15267
15289
  /** Properties of a PartitionedDml. */
15268
15290
  interface IPartitionedDml {
15269
15291
  }
@@ -36999,6 +36999,7 @@
36999
36999
  * @interface IResultSetMetadata
37000
37000
  * @property {google.spanner.v1.IStructType|null} [rowType] ResultSetMetadata rowType
37001
37001
  * @property {google.spanner.v1.ITransaction|null} [transaction] ResultSetMetadata transaction
37002
+ * @property {google.spanner.v1.IStructType|null} [undeclaredParameters] ResultSetMetadata undeclaredParameters
37002
37003
  */
37003
37004
 
37004
37005
  /**
@@ -37032,6 +37033,14 @@
37032
37033
  */
37033
37034
  ResultSetMetadata.prototype.transaction = null;
37034
37035
 
37036
+ /**
37037
+ * ResultSetMetadata undeclaredParameters.
37038
+ * @member {google.spanner.v1.IStructType|null|undefined} undeclaredParameters
37039
+ * @memberof google.spanner.v1.ResultSetMetadata
37040
+ * @instance
37041
+ */
37042
+ ResultSetMetadata.prototype.undeclaredParameters = null;
37043
+
37035
37044
  /**
37036
37045
  * Creates a new ResultSetMetadata instance using the specified properties.
37037
37046
  * @function create
@@ -37060,6 +37069,8 @@
37060
37069
  $root.google.spanner.v1.StructType.encode(message.rowType, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
37061
37070
  if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction"))
37062
37071
  $root.google.spanner.v1.Transaction.encode(message.transaction, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
37072
+ if (message.undeclaredParameters != null && Object.hasOwnProperty.call(message, "undeclaredParameters"))
37073
+ $root.google.spanner.v1.StructType.encode(message.undeclaredParameters, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
37063
37074
  return writer;
37064
37075
  };
37065
37076
 
@@ -37102,6 +37113,10 @@
37102
37113
  message.transaction = $root.google.spanner.v1.Transaction.decode(reader, reader.uint32());
37103
37114
  break;
37104
37115
  }
37116
+ case 3: {
37117
+ message.undeclaredParameters = $root.google.spanner.v1.StructType.decode(reader, reader.uint32());
37118
+ break;
37119
+ }
37105
37120
  default:
37106
37121
  reader.skipType(tag & 7);
37107
37122
  break;
@@ -37147,6 +37162,11 @@
37147
37162
  if (error)
37148
37163
  return "transaction." + error;
37149
37164
  }
37165
+ if (message.undeclaredParameters != null && message.hasOwnProperty("undeclaredParameters")) {
37166
+ var error = $root.google.spanner.v1.StructType.verify(message.undeclaredParameters);
37167
+ if (error)
37168
+ return "undeclaredParameters." + error;
37169
+ }
37150
37170
  return null;
37151
37171
  };
37152
37172
 
@@ -37172,6 +37192,11 @@
37172
37192
  throw TypeError(".google.spanner.v1.ResultSetMetadata.transaction: object expected");
37173
37193
  message.transaction = $root.google.spanner.v1.Transaction.fromObject(object.transaction);
37174
37194
  }
37195
+ if (object.undeclaredParameters != null) {
37196
+ if (typeof object.undeclaredParameters !== "object")
37197
+ throw TypeError(".google.spanner.v1.ResultSetMetadata.undeclaredParameters: object expected");
37198
+ message.undeclaredParameters = $root.google.spanner.v1.StructType.fromObject(object.undeclaredParameters);
37199
+ }
37175
37200
  return message;
37176
37201
  };
37177
37202
 
@@ -37191,11 +37216,14 @@
37191
37216
  if (options.defaults) {
37192
37217
  object.rowType = null;
37193
37218
  object.transaction = null;
37219
+ object.undeclaredParameters = null;
37194
37220
  }
37195
37221
  if (message.rowType != null && message.hasOwnProperty("rowType"))
37196
37222
  object.rowType = $root.google.spanner.v1.StructType.toObject(message.rowType, options);
37197
37223
  if (message.transaction != null && message.hasOwnProperty("transaction"))
37198
37224
  object.transaction = $root.google.spanner.v1.Transaction.toObject(message.transaction, options);
37225
+ if (message.undeclaredParameters != null && message.hasOwnProperty("undeclaredParameters"))
37226
+ object.undeclaredParameters = $root.google.spanner.v1.StructType.toObject(message.undeclaredParameters, options);
37199
37227
  return object;
37200
37228
  };
37201
37229
 
@@ -37856,6 +37884,7 @@
37856
37884
  * Properties of a ReadWrite.
37857
37885
  * @memberof google.spanner.v1.TransactionOptions
37858
37886
  * @interface IReadWrite
37887
+ * @property {google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode|null} [readLockMode] ReadWrite readLockMode
37859
37888
  */
37860
37889
 
37861
37890
  /**
@@ -37873,6 +37902,14 @@
37873
37902
  this[keys[i]] = properties[keys[i]];
37874
37903
  }
37875
37904
 
37905
+ /**
37906
+ * ReadWrite readLockMode.
37907
+ * @member {google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode} readLockMode
37908
+ * @memberof google.spanner.v1.TransactionOptions.ReadWrite
37909
+ * @instance
37910
+ */
37911
+ ReadWrite.prototype.readLockMode = 0;
37912
+
37876
37913
  /**
37877
37914
  * Creates a new ReadWrite instance using the specified properties.
37878
37915
  * @function create
@@ -37897,6 +37934,8 @@
37897
37934
  ReadWrite.encode = function encode(message, writer) {
37898
37935
  if (!writer)
37899
37936
  writer = $Writer.create();
37937
+ if (message.readLockMode != null && Object.hasOwnProperty.call(message, "readLockMode"))
37938
+ writer.uint32(/* id 1, wireType 0 =*/8).int32(message.readLockMode);
37900
37939
  return writer;
37901
37940
  };
37902
37941
 
@@ -37931,6 +37970,10 @@
37931
37970
  while (reader.pos < end) {
37932
37971
  var tag = reader.uint32();
37933
37972
  switch (tag >>> 3) {
37973
+ case 1: {
37974
+ message.readLockMode = reader.int32();
37975
+ break;
37976
+ }
37934
37977
  default:
37935
37978
  reader.skipType(tag & 7);
37936
37979
  break;
@@ -37966,6 +38009,15 @@
37966
38009
  ReadWrite.verify = function verify(message) {
37967
38010
  if (typeof message !== "object" || message === null)
37968
38011
  return "object expected";
38012
+ if (message.readLockMode != null && message.hasOwnProperty("readLockMode"))
38013
+ switch (message.readLockMode) {
38014
+ default:
38015
+ return "readLockMode: enum value expected";
38016
+ case 0:
38017
+ case 1:
38018
+ case 2:
38019
+ break;
38020
+ }
37969
38021
  return null;
37970
38022
  };
37971
38023
 
@@ -37980,7 +38032,28 @@
37980
38032
  ReadWrite.fromObject = function fromObject(object) {
37981
38033
  if (object instanceof $root.google.spanner.v1.TransactionOptions.ReadWrite)
37982
38034
  return object;
37983
- return new $root.google.spanner.v1.TransactionOptions.ReadWrite();
38035
+ var message = new $root.google.spanner.v1.TransactionOptions.ReadWrite();
38036
+ switch (object.readLockMode) {
38037
+ default:
38038
+ if (typeof object.readLockMode === "number") {
38039
+ message.readLockMode = object.readLockMode;
38040
+ break;
38041
+ }
38042
+ break;
38043
+ case "READ_LOCK_MODE_UNSPECIFIED":
38044
+ case 0:
38045
+ message.readLockMode = 0;
38046
+ break;
38047
+ case "PESSIMISTIC":
38048
+ case 1:
38049
+ message.readLockMode = 1;
38050
+ break;
38051
+ case "OPTIMISTIC":
38052
+ case 2:
38053
+ message.readLockMode = 2;
38054
+ break;
38055
+ }
38056
+ return message;
37984
38057
  };
37985
38058
 
37986
38059
  /**
@@ -37992,8 +38065,15 @@
37992
38065
  * @param {$protobuf.IConversionOptions} [options] Conversion options
37993
38066
  * @returns {Object.<string,*>} Plain object
37994
38067
  */
37995
- ReadWrite.toObject = function toObject() {
37996
- return {};
38068
+ ReadWrite.toObject = function toObject(message, options) {
38069
+ if (!options)
38070
+ options = {};
38071
+ var object = {};
38072
+ if (options.defaults)
38073
+ object.readLockMode = options.enums === String ? "READ_LOCK_MODE_UNSPECIFIED" : 0;
38074
+ if (message.readLockMode != null && message.hasOwnProperty("readLockMode"))
38075
+ object.readLockMode = options.enums === String ? $root.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode[message.readLockMode] === undefined ? message.readLockMode : $root.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode[message.readLockMode] : message.readLockMode;
38076
+ return object;
37997
38077
  };
37998
38078
 
37999
38079
  /**
@@ -38022,6 +38102,22 @@
38022
38102
  return typeUrlPrefix + "/google.spanner.v1.TransactionOptions.ReadWrite";
38023
38103
  };
38024
38104
 
38105
+ /**
38106
+ * ReadLockMode enum.
38107
+ * @name google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode
38108
+ * @enum {number}
38109
+ * @property {number} READ_LOCK_MODE_UNSPECIFIED=0 READ_LOCK_MODE_UNSPECIFIED value
38110
+ * @property {number} PESSIMISTIC=1 PESSIMISTIC value
38111
+ * @property {number} OPTIMISTIC=2 OPTIMISTIC value
38112
+ */
38113
+ ReadWrite.ReadLockMode = (function() {
38114
+ var valuesById = {}, values = Object.create(valuesById);
38115
+ values[valuesById[0] = "READ_LOCK_MODE_UNSPECIFIED"] = 0;
38116
+ values[valuesById[1] = "PESSIMISTIC"] = 1;
38117
+ values[valuesById[2] = "OPTIMISTIC"] = 2;
38118
+ return values;
38119
+ })();
38120
+
38025
38121
  return ReadWrite;
38026
38122
  })();
38027
38123
 
@@ -3869,6 +3869,10 @@
3869
3869
  "transaction": {
3870
3870
  "type": "Transaction",
3871
3871
  "id": 2
3872
+ },
3873
+ "undeclaredParameters": {
3874
+ "type": "StructType",
3875
+ "id": 3
3872
3876
  }
3873
3877
  }
3874
3878
  },
@@ -3926,7 +3930,21 @@
3926
3930
  },
3927
3931
  "nested": {
3928
3932
  "ReadWrite": {
3929
- "fields": {}
3933
+ "fields": {
3934
+ "readLockMode": {
3935
+ "type": "ReadLockMode",
3936
+ "id": 1
3937
+ }
3938
+ },
3939
+ "nested": {
3940
+ "ReadLockMode": {
3941
+ "values": {
3942
+ "READ_LOCK_MODE_UNSPECIFIED": 0,
3943
+ "PESSIMISTIC": 1,
3944
+ "OPTIMISTIC": 2
3945
+ }
3946
+ }
3947
+ }
3930
3948
  },
3931
3949
  "PartitionedDml": {
3932
3950
  "fields": {}
@@ -19,12 +19,12 @@ import { CallOptions, Metadata, Operation as GaxOperation } from 'google-gax';
19
19
  import { PreciseDate } from '@google-cloud/precise-date';
20
20
  import { google as databaseAdmin } from '../protos/protos';
21
21
  import { common as p } from 'protobufjs';
22
- export declare type CreateBackupCallback = LongRunningCallback<Backup>;
23
- export declare type CopyBackupCallback = LongRunningCallback<Backup>;
22
+ export type CreateBackupCallback = LongRunningCallback<Backup>;
23
+ export type CopyBackupCallback = LongRunningCallback<Backup>;
24
24
  export interface CreateBackupGaxOperation extends GaxOperation {
25
25
  metadata: Metadata & databaseAdmin.spanner.admin.database.v1.ICreateBackupMetadata;
26
26
  }
27
- export declare type CreateBackupResponse = [
27
+ export type CreateBackupResponse = [
28
28
  Backup,
29
29
  CreateBackupGaxOperation,
30
30
  IOperation
@@ -39,25 +39,25 @@ export interface CreateBackupOptions {
39
39
  export interface CopyBackupGaxOperation extends GaxOperation {
40
40
  metadata: Metadata & databaseAdmin.spanner.admin.database.v1.ICopyBackupMetadata;
41
41
  }
42
- export declare type CopyBackupResponse = [Backup, CopyBackupGaxOperation, IOperation];
42
+ export type CopyBackupResponse = [Backup, CopyBackupGaxOperation, IOperation];
43
43
  export interface CopyBackupOptions extends databaseAdmin.spanner.admin.database.v1.ICopyBackupRequest {
44
44
  gaxOptions?: CallOptions;
45
45
  }
46
46
  /**
47
47
  * IBackup structure with backup state enum translated to string form.
48
48
  */
49
- declare type IBackupTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IBackup, 'state', typeof databaseAdmin.spanner.admin.database.v1.Backup.State>;
50
- export declare type GetMetadataResponse = [IBackupTranslatedEnum];
51
- declare type GetMetadataCallback = RequestCallback<IBackupTranslatedEnum>;
52
- declare type UpdateExpireTimeCallback = RequestCallback<databaseAdmin.spanner.admin.database.v1.IBackup>;
53
- declare type DeleteCallback = RequestCallback<databaseAdmin.protobuf.IEmpty>;
49
+ type IBackupTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IBackup, 'state', typeof databaseAdmin.spanner.admin.database.v1.Backup.State>;
50
+ export type GetMetadataResponse = [IBackupTranslatedEnum];
51
+ type GetMetadataCallback = RequestCallback<IBackupTranslatedEnum>;
52
+ type UpdateExpireTimeCallback = RequestCallback<databaseAdmin.spanner.admin.database.v1.IBackup>;
53
+ type DeleteCallback = RequestCallback<databaseAdmin.protobuf.IEmpty>;
54
54
  interface BackupRequest {
55
55
  (config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
56
56
  <T>(config: RequestConfig, callback: RequestCallback<T>): void;
57
57
  }
58
- export declare type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Backup.State>>;
59
- export declare type GetExpireTimeCallback = NormalCallback<PreciseDate>;
60
- export declare type ExistsCallback = NormalCallback<boolean>;
58
+ export type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Backup.State>>;
59
+ export type GetExpireTimeCallback = NormalCallback<PreciseDate>;
60
+ export type ExistsCallback = NormalCallback<boolean>;
61
61
  /**
62
62
  * The {@link Backup} class represents a Cloud Spanner backup.
63
63
  *
@@ -1,7 +1,7 @@
1
1
  import { Big } from 'big.js';
2
2
  import { common as p } from 'protobufjs';
3
3
  import { google as spannerClient } from '../protos/protos';
4
- export declare type Value = any;
4
+ export type Value = any;
5
5
  export interface Field {
6
6
  name: string;
7
7
  value: Value;
@@ -130,6 +130,15 @@ export declare class PGNumeric {
130
130
  valueOf(): Big;
131
131
  toJSON(): string;
132
132
  }
133
+ /**
134
+ * @typedef PGJsonb
135
+ * @see Spanner.pgJsonb
136
+ */
137
+ export declare class PGJsonb {
138
+ value: object;
139
+ constructor(pgValue: object | string);
140
+ toString(): string;
141
+ }
133
142
  /**
134
143
  * @typedef JSONOptions
135
144
  * @property {boolean} [wrapNumbers=false] Indicates if the numbers should be
@@ -268,6 +277,7 @@ export declare const codec: {
268
277
  Int: typeof Int;
269
278
  Numeric: typeof Numeric;
270
279
  PGNumeric: typeof PGNumeric;
280
+ PGJsonb: typeof PGJsonb;
271
281
  convertFieldsToJson: typeof convertFieldsToJson;
272
282
  decode: typeof decode;
273
283
  encode: typeof encode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.codec = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.SpannerDate = void 0;
3
+ exports.codec = exports.PGJsonb = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.SpannerDate = void 0;
4
4
  /*!
5
5
  * Copyright 2017 Google Inc. All Rights Reserved.
6
6
  *
@@ -195,6 +195,22 @@ class PGNumeric {
195
195
  }
196
196
  }
197
197
  exports.PGNumeric = PGNumeric;
198
+ /**
199
+ * @typedef PGJsonb
200
+ * @see Spanner.pgJsonb
201
+ */
202
+ class PGJsonb {
203
+ constructor(pgValue) {
204
+ if (typeof pgValue === 'string') {
205
+ pgValue = JSON.parse(pgValue);
206
+ }
207
+ this.value = pgValue;
208
+ }
209
+ toString() {
210
+ return JSON.stringify(this.value);
211
+ }
212
+ }
213
+ exports.PGJsonb = PGJsonb;
198
214
  /**
199
215
  * @typedef JSONOptions
200
216
  * @property {boolean} [wrapNumbers=false] Indicates if the numbers should be
@@ -318,6 +334,12 @@ function decode(value, type) {
318
334
  break;
319
335
  case protos_1.google.spanner.v1.TypeCode.JSON:
320
336
  case 'JSON':
337
+ if (type.typeAnnotation ===
338
+ protos_1.google.spanner.v1.TypeAnnotationCode.PG_JSONB ||
339
+ type.typeAnnotation === 'PG_JSONB') {
340
+ decoded = new PGJsonb(decoded);
341
+ break;
342
+ }
321
343
  decoded = JSON.parse(decoded);
322
344
  break;
323
345
  case protos_1.google.spanner.v1.TypeCode.ARRAY:
@@ -385,6 +407,9 @@ function encodeValue(value) {
385
407
  if (is.array(value)) {
386
408
  return value.map(encodeValue);
387
409
  }
410
+ if (value instanceof PGJsonb) {
411
+ return value.toString();
412
+ }
388
413
  if (is.object(value)) {
389
414
  return JSON.stringify(value);
390
415
  }
@@ -408,6 +433,7 @@ const TypeCode = {
408
433
  string: 'STRING',
409
434
  bytes: 'BYTES',
410
435
  json: 'JSON',
436
+ jsonb: 'JSON',
411
437
  array: 'ARRAY',
412
438
  struct: 'STRUCT',
413
439
  };
@@ -462,6 +488,9 @@ function getType(value) {
462
488
  if (value instanceof PGNumeric) {
463
489
  return { type: 'pgNumeric' };
464
490
  }
491
+ if (value instanceof PGJsonb) {
492
+ return { type: 'pgJsonb' };
493
+ }
465
494
  if (is.boolean(value)) {
466
495
  return { type: 'bool' };
467
496
  }
@@ -576,6 +605,9 @@ function createTypeObject(friendlyType) {
576
605
  type.typeAnnotation =
577
606
  protos_1.google.spanner.v1.TypeAnnotationCode.PG_NUMERIC;
578
607
  }
608
+ else if (friendlyType.type === 'jsonb') {
609
+ type.typeAnnotation = protos_1.google.spanner.v1.TypeAnnotationCode.PG_JSONB;
610
+ }
579
611
  return type;
580
612
  }
581
613
  exports.codec = {
@@ -588,6 +620,7 @@ exports.codec = {
588
620
  Int,
589
621
  Numeric,
590
622
  PGNumeric,
623
+ PGJsonb,
591
624
  convertFieldsToJson,
592
625
  decode,
593
626
  encode,