@zenstackhq/orm 3.8.0-beta.3 → 3.8.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.cjs CHANGED
@@ -1474,7 +1474,10 @@ var LateralJoinDialectBase = class extends BaseCrudDialect {
1474
1474
  return { [field]: fieldValue };
1475
1475
  }
1476
1476
  }));
1477
- if (typeof payload === "object" && payload.include && typeof payload.include === "object") Object.assign(objArgs, ...Object.entries(payload.include).filter(([, value]) => value).map(([field]) => ({ [field]: eb.ref(`${parentResultName}$${field}.$data`) })));
1477
+ if (typeof payload === "object" && payload.include && typeof payload.include === "object") Object.assign(objArgs, ...Object.entries(payload.include).filter(([, value]) => value).map(([field, value]) => {
1478
+ if (field === "_count") return { [field]: this.buildCountJson(relationModel, eb, relationModelAlias, value) };
1479
+ return { [field]: eb.ref(`${parentResultName}$${field}.$data`) };
1480
+ }));
1478
1481
  return objArgs;
1479
1482
  }
1480
1483
  buildRelationJoins(query, relationModel, relationModelAlias, payload, parentResultName) {
@@ -2149,6 +2152,10 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
2149
2152
  } else return [kysely.sql.lit(field), this.fieldRef(relationModel, field, subQueryName, false)];
2150
2153
  }).flatMap((v) => v));
2151
2154
  if (typeof payload === "object" && payload.include && typeof payload.include === "object") objArgs.push(...Object.entries(payload.include).filter(([, value]) => value).map(([field, value]) => {
2155
+ if (field === "_count") {
2156
+ const subJson = this.buildCountJson(relationModel, eb, tmpAlias(`${parentAlias}$${relationField}`), value);
2157
+ return [kysely.sql.lit(field), subJson];
2158
+ }
2152
2159
  const subJson = this.buildRelationJSON(relationModel, eb, field, tmpAlias(`${parentAlias}$${relationField}`), value);
2153
2160
  return [kysely.sql.lit(field), subJson];
2154
2161
  }).flatMap((v) => v));