@solidstarters/solid-core 1.2.33 → 1.2.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.33",
3
+ "version": "1.2.34",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -173,7 +173,7 @@ export class CrudHelperService {
173
173
  if (normalizedFields && normalizedFields.length) {
174
174
  qb.select(normalizedFields.map(field => {
175
175
  // If the field contains a (, do not prefix the entity alias
176
- return this.isAggregateField(field) ? field : `${entityAlias}.${field}`;
176
+ return this.wrapFieldWithAlias(field, entityAlias);
177
177
  }));
178
178
  }
179
179
 
@@ -220,6 +220,15 @@ export class CrudHelperService {
220
220
  return qb;
221
221
  }
222
222
 
223
+ private wrapFieldWithAlias(field: string, entityAlias: string): string {
224
+ if (!this.isAggregateField(field)) return `${entityAlias}.${field}`;
225
+ // For aggregate fields, extract the field name from the aggregate function & wrap it with the entity alias, if it is not already wrapped
226
+ const fieldParts = field.split('(');
227
+ const aggregateFunction = fieldParts[0];
228
+ const fieldName = fieldParts[1].replace(')', '');
229
+ return `${aggregateFunction}(${entityAlias}.${fieldName})`;
230
+ }
231
+
223
232
  isAggregateField(field: string): boolean {
224
233
  return field.includes('(');
225
234
  }