prisma-sql 1.49.0 → 1.50.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
@@ -4110,6 +4110,12 @@ var HAVING_FIELD_FIRST_AGG_KEYS = Object.freeze([
4110
4110
  "_min",
4111
4111
  "_max"
4112
4112
  ]);
4113
+ function hasAnyOwnKey(obj) {
4114
+ for (const k in obj) {
4115
+ if (Object.prototype.hasOwnProperty.call(obj, k)) return true;
4116
+ }
4117
+ return false;
4118
+ }
4113
4119
  function isTruthySelection(v) {
4114
4120
  return v === true;
4115
4121
  }
@@ -4262,14 +4268,7 @@ function buildHavingForAggregateFirstShape(aggKey, target, alias, params, dialec
4262
4268
  const filter = targetObj[field];
4263
4269
  if (!isPlainObject(filter)) continue;
4264
4270
  const filterObj = filter;
4265
- let hasAny = false;
4266
- for (const k in filterObj) {
4267
- if (Object.prototype.hasOwnProperty.call(filterObj, k)) {
4268
- hasAny = true;
4269
- break;
4270
- }
4271
- }
4272
- if (!hasAny) continue;
4271
+ if (!hasAnyOwnKey(filterObj)) continue;
4273
4272
  const expr = aggExprForField(aggKey, field, alias, model);
4274
4273
  out.push(...buildHavingOpsForExpr(expr, filterObj, params, dialect));
4275
4274
  }
@@ -4286,14 +4285,7 @@ function buildHavingForFieldFirstShape(fieldName, target, alias, params, dialect
4286
4285
  const aggFilter = obj[aggKey];
4287
4286
  if (!isPlainObject(aggFilter)) continue;
4288
4287
  const aggFilterObj = aggFilter;
4289
- let hasAny = false;
4290
- for (const k in aggFilterObj) {
4291
- if (Object.prototype.hasOwnProperty.call(aggFilterObj, k)) {
4292
- hasAny = true;
4293
- break;
4294
- }
4295
- }
4296
- if (!hasAny) continue;
4288
+ if (!hasAnyOwnKey(aggFilterObj)) continue;
4297
4289
  if (aggKey === "_sum" || aggKey === "_avg") {
4298
4290
  assertNumericField(model, fieldName, "HAVING");
4299
4291
  }