@azure/data-tables 13.1.3-alpha.20220725.1 → 13.2.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/dist/index.js CHANGED
@@ -3502,7 +3502,7 @@ function signURLWithSAS(request, credential) {
3502
3502
  const tracingClient = coreTracing.createTracingClient({
3503
3503
  namespace: "Microsoft.Data.Tables",
3504
3504
  packageName: "@azure/data-tables",
3505
- packageVersion: "13.1.3",
3505
+ packageVersion: "13.2.0",
3506
3506
  });
3507
3507
 
3508
3508
  // Copyright (c) Microsoft Corporation.
@@ -3884,11 +3884,14 @@ class TableTransaction {
3884
3884
  /**
3885
3885
  * Adds an update action to the transaction
3886
3886
  * @param entity - entity to update
3887
- * @param updateMode - update mode
3888
- * @param options - options for the update operation
3887
+ * @param updateModeOrOptions - update mode or update options
3888
+ * @param updateOptions - options for the update operation
3889
3889
  */
3890
- updateEntity(entity, updateMode = "Merge", updateOptions) {
3891
- this.actions.push(["update", entity, updateMode, updateOptions]);
3890
+ updateEntity(entity, updateModeOrOptions, updateOptions) {
3891
+ // UpdateMode is a string union
3892
+ const realUpdateMode = typeof updateModeOrOptions === "string" ? updateModeOrOptions : undefined;
3893
+ const realUpdateOptions = typeof updateModeOrOptions === "object" ? updateModeOrOptions : updateOptions;
3894
+ this.actions.push(["update", entity, realUpdateMode !== null && realUpdateMode !== void 0 ? realUpdateMode : "Merge", realUpdateOptions !== null && realUpdateOptions !== void 0 ? realUpdateOptions : {}]);
3892
3895
  }
3893
3896
  /**
3894
3897
  * Adds an upsert action to the transaction, which inserts if the entity doesn't exist or updates the existing one
@@ -4385,7 +4388,7 @@ function escapeQuotesIfString(input, previous) {
4385
4388
  if (typeof input === "string") {
4386
4389
  result = escapeQuotes(input);
4387
4390
  // check if we need to escape this literal
4388
- if (!previous.trim().endsWith("'")) {
4391
+ if (previous !== "" && !previous.trim().endsWith("'")) {
4389
4392
  result = `'${result}'`;
4390
4393
  }
4391
4394
  }
@@ -4394,15 +4397,22 @@ function escapeQuotesIfString(input, previous) {
4394
4397
  function escapeQuotes(input) {
4395
4398
  return input.replace(/'/g, "''");
4396
4399
  }
4400
+ function encodeDate(input) {
4401
+ return input instanceof Date ? `datetime'${input.toISOString()}'` : input;
4402
+ }
4397
4403
  /**
4398
4404
  * Escapes an odata filter expression to avoid errors with quoting string literals.
4405
+ * Encodes Date objects.
4399
4406
  */
4400
4407
  function odata(strings, ...values) {
4408
+ const fixEncoding = (value, string) => {
4409
+ return encodeDate(escapeQuotesIfString(value, string));
4410
+ };
4401
4411
  const results = [];
4402
4412
  for (let i = 0; i < strings.length; i++) {
4403
4413
  results.push(strings[i]);
4404
4414
  if (i < values.length) {
4405
- results.push(escapeQuotesIfString(values[i], strings[i]));
4415
+ results.push(fixEncoding(values[i], strings[i]));
4406
4416
  }
4407
4417
  }
4408
4418
  return results.join("");