@electric-sql/client 1.2.1 → 1.2.2

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.
@@ -270,6 +270,10 @@ function makeNullableParser(parser, columnInfo, columnName) {
270
270
  }
271
271
 
272
272
  // src/column-mapper.ts
273
+ function quoteIdentifier(identifier) {
274
+ const escaped = identifier.replace(/"/g, `""`);
275
+ return `"${escaped}"`;
276
+ }
273
277
  function snakeToCamel(str) {
274
278
  var _a, _b, _c, _d;
275
279
  const leadingUnderscores = (_b = (_a = str.match(/^_+/)) == null ? void 0 : _a[0]) != null ? _b : ``;
@@ -1417,7 +1421,7 @@ requestShape_fn = async function() {
1417
1421
  return __privateMethod(this, _ShapeStream_instances, requestShape_fn).call(this);
1418
1422
  };
1419
1423
  constructUrl_fn = async function(url, resumingFromPause, subsetParams) {
1420
- var _a, _b, _c;
1424
+ var _a, _b, _c, _d;
1421
1425
  const [requestHeaders, params] = await Promise.all([
1422
1426
  resolveHeaders(this.options.headers),
1423
1427
  this.options.params ? toInternalParams(convertWhereParamsToObj(this.options.params)) : void 0
@@ -1433,8 +1437,21 @@ constructUrl_fn = async function(url, resumingFromPause, subsetParams) {
1433
1437
  );
1434
1438
  setQueryParam(fetchUrl, WHERE_QUERY_PARAM, encodedWhere);
1435
1439
  }
1436
- if (params.columns)
1437
- setQueryParam(fetchUrl, COLUMNS_QUERY_PARAM, params.columns);
1440
+ if (params.columns) {
1441
+ const originalColumns = await resolveValue((_b = this.options.params) == null ? void 0 : _b.columns);
1442
+ if (Array.isArray(originalColumns)) {
1443
+ let encodedColumns = originalColumns.map(String);
1444
+ if (this.options.columnMapper) {
1445
+ encodedColumns = encodedColumns.map(
1446
+ this.options.columnMapper.encode
1447
+ );
1448
+ }
1449
+ const serializedColumns = encodedColumns.map(quoteIdentifier).join(`,`);
1450
+ setQueryParam(fetchUrl, COLUMNS_QUERY_PARAM, serializedColumns);
1451
+ } else {
1452
+ setQueryParam(fetchUrl, COLUMNS_QUERY_PARAM, params.columns);
1453
+ }
1454
+ }
1438
1455
  if (params.replica) setQueryParam(fetchUrl, REPLICA_PARAM, params.replica);
1439
1456
  if (params.params)
1440
1457
  setQueryParam(fetchUrl, WHERE_PARAMS_PARAM, params.params);
@@ -1452,7 +1469,7 @@ constructUrl_fn = async function(url, resumingFromPause, subsetParams) {
1452
1469
  if (subsetParams.where && typeof subsetParams.where === `string`) {
1453
1470
  const encodedWhere = encodeWhereClause(
1454
1471
  subsetParams.where,
1455
- (_b = this.options.columnMapper) == null ? void 0 : _b.encode
1472
+ (_c = this.options.columnMapper) == null ? void 0 : _c.encode
1456
1473
  );
1457
1474
  setQueryParam(fetchUrl, SUBSET_PARAM_WHERE, encodedWhere);
1458
1475
  }
@@ -1468,7 +1485,7 @@ constructUrl_fn = async function(url, resumingFromPause, subsetParams) {
1468
1485
  if (subsetParams.orderBy && typeof subsetParams.orderBy === `string`) {
1469
1486
  const encodedOrderBy = encodeWhereClause(
1470
1487
  subsetParams.orderBy,
1471
- (_c = this.options.columnMapper) == null ? void 0 : _c.encode
1488
+ (_d = this.options.columnMapper) == null ? void 0 : _d.encode
1472
1489
  );
1473
1490
  setQueryParam(fetchUrl, SUBSET_PARAM_ORDER_BY, encodedOrderBy);
1474
1491
  }