@rebasepro/server-postgres 0.19.2-canary.g7199920 → 0.19.2-canary.g98b88fd

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.es.js CHANGED
@@ -3552,28 +3552,6 @@ function compareForSort(a, b, nullsLast) {
3552
3552
  * Service for handling all row read operations.
3553
3553
  * Handles fetching, searching, counting, and filtering rows.
3554
3554
  */
3555
- /**
3556
- * Which aggregate aliases hold a number that Postgres handed back as a string.
3557
- *
3558
- * `count`, `sum` and `avg` always do: bigint and numeric are returned as text
3559
- * because they do not fit a JS number in general. `min` and `max` are uncast,
3560
- * so they do it too — but only over a numeric column, and those are the two
3561
- * functions that also apply to text and dates.
3562
- *
3563
- * Decided by the column's DECLARED type, not by trying `Number()` on the value.
3564
- * `?select=avg(price),max(price)` used to answer `{avg_price: 5,
3565
- * max_price: "8.5"}` — one column, two functions, two JSON types, and
3566
- * arithmetic on the second one silently concatenates. Parsing whatever looks
3567
- * numeric would fix that and break something worse: a `min(sku)` of `"00123"`
3568
- * would come back as `123`, a different value, and no NaN check would catch it.
3569
- *
3570
- * Exported to be tested: the parsing itself needs a database, this decision
3571
- * does not.
3572
- */
3573
- function numericAggregateAliases(aggregates, properties) {
3574
- const isNumberField = (field) => Boolean(field) && properties[field]?.type === "number";
3575
- return new Set(aggregates.filter((a) => a.fn === "count" || a.fn === "sum" || a.fn === "avg" || (a.fn === "min" || a.fn === "max") && isNumberField(a.field)).map((a) => a.alias));
3576
- }
3577
3555
  var FetchService = class FetchService {
3578
3556
  db;
3579
3557
  registry;
@@ -4414,7 +4392,7 @@ var FetchService = class FetchService {
4414
4392
  if (options.limit) query = query.limit(options.limit);
4415
4393
  }
4416
4394
  const rows = await query;
4417
- const numericAliases = numericAggregateAliases(options.aggregates, collection?.properties ?? {});
4395
+ const numericAliases = new Set(options.aggregates.filter((a) => a.fn === "count" || a.fn === "sum" || a.fn === "avg").map((a) => a.alias));
4418
4396
  return rows.map((row) => {
4419
4397
  const out = { ...row };
4420
4398
  for (const alias of numericAliases) {
@@ -5179,7 +5157,7 @@ var PersistService = class {
5179
5157
  } catch (error) {
5180
5158
  throw this.toUserFriendlyError(error, collection.slug, collection);
5181
5159
  }
5182
- const finalEntity = await this.fetchService.fetchOneForRest(collection.slug, savedId, void 0, databaseId, { withDeleted: true });
5160
+ const finalEntity = await this.fetchService.fetchOneForRest(collection.slug, savedId, void 0, databaseId);
5183
5161
  if (!finalEntity) throw new Error("Could not fetch row after save.");
5184
5162
  return finalEntity;
5185
5163
  }