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/generator.js CHANGED
@@ -54,7 +54,7 @@ var require_package = __commonJS({
54
54
  "package.json"(exports$1, module) {
55
55
  module.exports = {
56
56
  name: "prisma-sql",
57
- version: "1.49.0",
57
+ version: "1.50.0",
58
58
  description: "Convert Prisma queries to optimized SQL with type safety. 2-7x faster than Prisma Client.",
59
59
  main: "dist/index.cjs",
60
60
  module: "dist/index.js",
@@ -4219,6 +4219,12 @@ var HAVING_FIELD_FIRST_AGG_KEYS = Object.freeze([
4219
4219
  "_min",
4220
4220
  "_max"
4221
4221
  ]);
4222
+ function hasAnyOwnKey(obj) {
4223
+ for (const k in obj) {
4224
+ if (Object.prototype.hasOwnProperty.call(obj, k)) return true;
4225
+ }
4226
+ return false;
4227
+ }
4222
4228
  function isTruthySelection(v) {
4223
4229
  return v === true;
4224
4230
  }
@@ -4371,14 +4377,7 @@ function buildHavingForAggregateFirstShape(aggKey, target, alias, params, dialec
4371
4377
  const filter = targetObj[field];
4372
4378
  if (!isPlainObject(filter)) continue;
4373
4379
  const filterObj = filter;
4374
- let hasAny = false;
4375
- for (const k in filterObj) {
4376
- if (Object.prototype.hasOwnProperty.call(filterObj, k)) {
4377
- hasAny = true;
4378
- break;
4379
- }
4380
- }
4381
- if (!hasAny) continue;
4380
+ if (!hasAnyOwnKey(filterObj)) continue;
4382
4381
  const expr = aggExprForField(aggKey, field, alias, model);
4383
4382
  out.push(...buildHavingOpsForExpr(expr, filterObj, params, dialect));
4384
4383
  }
@@ -4395,14 +4394,7 @@ function buildHavingForFieldFirstShape(fieldName, target, alias, params, dialect
4395
4394
  const aggFilter = obj[aggKey];
4396
4395
  if (!isPlainObject(aggFilter)) continue;
4397
4396
  const aggFilterObj = aggFilter;
4398
- let hasAny = false;
4399
- for (const k in aggFilterObj) {
4400
- if (Object.prototype.hasOwnProperty.call(aggFilterObj, k)) {
4401
- hasAny = true;
4402
- break;
4403
- }
4404
- }
4405
- if (!hasAny) continue;
4397
+ if (!hasAnyOwnKey(aggFilterObj)) continue;
4406
4398
  if (aggKey === "_sum" || aggKey === "_avg") {
4407
4399
  assertNumericField(model, fieldName, "HAVING");
4408
4400
  }