@decaf-ts/core 0.8.26 → 0.8.28
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/README.md +184 -179
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/query/MethodQueryBuilder.d.ts +31 -3
- package/lib/esm/query/MethodQueryBuilder.js +153 -32
- package/lib/esm/query/MethodQueryBuilder.js.map +1 -1
- package/lib/esm/query/Statement.js +135 -7
- package/lib/esm/query/Statement.js.map +1 -1
- package/lib/esm/query/constants.d.ts +8 -1
- package/lib/esm/query/constants.js +7 -0
- package/lib/esm/query/constants.js.map +1 -1
- package/lib/esm/query/decorators.js +60 -6
- package/lib/esm/query/decorators.js.map +1 -1
- package/lib/esm/query/types.d.ts +21 -1
- package/lib/esm/query/types.js +8 -0
- package/lib/esm/query/types.js.map +1 -1
- package/lib/esm/repository/Repository.d.ts +56 -0
- package/lib/esm/repository/Repository.js +129 -0
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/services/ModelService.js +1 -1
- package/lib/esm/services/ModelService.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/query/MethodQueryBuilder.cjs +153 -32
- package/lib/query/MethodQueryBuilder.d.ts +31 -3
- package/lib/query/MethodQueryBuilder.js.map +1 -1
- package/lib/query/Statement.cjs +135 -7
- package/lib/query/Statement.js.map +1 -1
- package/lib/query/constants.cjs +7 -0
- package/lib/query/constants.d.ts +8 -1
- package/lib/query/constants.js.map +1 -1
- package/lib/query/decorators.cjs +60 -6
- package/lib/query/decorators.js.map +1 -1
- package/lib/query/types.cjs +8 -0
- package/lib/query/types.d.ts +21 -1
- package/lib/query/types.js.map +1 -1
- package/lib/repository/Repository.cjs +129 -0
- package/lib/repository/Repository.d.ts +56 -0
- package/lib/repository/Repository.js.map +1 -1
- package/lib/services/ModelService.cjs +1 -1
- package/lib/services/ModelService.js.map +1 -1
- package/package.json +1 -1
package/lib/esm/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export * from "./persistence";
|
|
|
21
21
|
* @const VERSION
|
|
22
22
|
* @memberOf module:core
|
|
23
23
|
*/
|
|
24
|
-
export declare const VERSION = "0.8.
|
|
24
|
+
export declare const VERSION = "0.8.27";
|
|
25
25
|
/**
|
|
26
26
|
* @description Stores the current package version
|
|
27
27
|
* @summary A constant representing the version of the core package
|
package/lib/esm/index.js
CHANGED
|
@@ -31,7 +31,7 @@ export * from "./persistence/index.js";
|
|
|
31
31
|
* @const VERSION
|
|
32
32
|
* @memberOf module:core
|
|
33
33
|
*/
|
|
34
|
-
export const VERSION = "0.8.
|
|
34
|
+
export const VERSION = "0.8.27";
|
|
35
35
|
/**
|
|
36
36
|
* @description Stores the current package version
|
|
37
37
|
* @summary A constant representing the version of the core package
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { QueryAssist } from "./types";
|
|
1
|
+
import { QueryAction, QueryAssist } from "./types";
|
|
2
2
|
import { LoggedClass, Logger } from "@decaf-ts/logging";
|
|
3
|
+
export type QueryActionPrefix = {
|
|
4
|
+
action: QueryAction;
|
|
5
|
+
prefix: string;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* @description
|
|
5
9
|
* Utility class to build query objects from repository method names.
|
|
@@ -56,6 +60,19 @@ import { LoggedClass, Logger } from "@decaf-ts/logging";
|
|
|
56
60
|
export declare class MethodQueryBuilder extends LoggedClass {
|
|
57
61
|
private static _logger;
|
|
58
62
|
protected static get log(): Logger;
|
|
63
|
+
/**
|
|
64
|
+
* @description
|
|
65
|
+
* Map of query prefixes to their corresponding actions.
|
|
66
|
+
*/
|
|
67
|
+
private static readonly prefixMap;
|
|
68
|
+
/**
|
|
69
|
+
* @description
|
|
70
|
+
* Determines the action and prefix length from a method name.
|
|
71
|
+
*
|
|
72
|
+
* @param methodName {string} - The repository method name.
|
|
73
|
+
* @return {QueryActionPrefix} | undefined} The action and prefix if found.
|
|
74
|
+
*/
|
|
75
|
+
private static getActionFromMethodName;
|
|
59
76
|
/**
|
|
60
77
|
* @description
|
|
61
78
|
* Builds a `QueryAssist` object by parsing a repository method name and values.
|
|
@@ -73,13 +90,23 @@ export declare class MethodQueryBuilder extends LoggedClass {
|
|
|
73
90
|
static build(methodName: string, ...values: any[]): QueryAssist;
|
|
74
91
|
/**
|
|
75
92
|
* @description
|
|
76
|
-
* Extracts the
|
|
93
|
+
* Extracts the aggregation selector field from method names like countByAge, sumByPrice.
|
|
94
|
+
*
|
|
95
|
+
* @param methodName {string} - The method name.
|
|
96
|
+
* @param prefix {string} - The prefix to remove.
|
|
97
|
+
* @return {string | undefined} The selector field name.
|
|
98
|
+
*/
|
|
99
|
+
private static extractAggregationSelector;
|
|
100
|
+
/**
|
|
101
|
+
* @description
|
|
102
|
+
* Extracts the core part of the method name after the prefix and before any special clauses.
|
|
77
103
|
*
|
|
78
104
|
* @summary
|
|
79
105
|
* Removes prefixes and detects delimiters (`Then`, `OrderBy`, `GroupBy`, `Limit`, `Offset`)
|
|
80
106
|
* to isolate the main conditional part of the query.
|
|
81
107
|
*
|
|
82
108
|
* @param methodName {string} - The method name to parse.
|
|
109
|
+
* @param prefix {string} - The prefix to remove (e.g., "findBy", "countBy").
|
|
83
110
|
*
|
|
84
111
|
* @return {string} The extracted core string used for building conditions.
|
|
85
112
|
*/
|
|
@@ -148,8 +175,9 @@ export declare class MethodQueryBuilder extends LoggedClass {
|
|
|
148
175
|
* Determines the number of condition arguments, then checks the remaining arguments
|
|
149
176
|
* to resolve sorting, limiting, and pagination.
|
|
150
177
|
*
|
|
151
|
-
* @param methodName {string} - The
|
|
178
|
+
* @param methodName {string} - The method name.
|
|
152
179
|
* @param values {any[]} - The values corresponding to method arguments, including conditions and extras.
|
|
180
|
+
* @param core {string} - The pre-extracted core string.
|
|
153
181
|
*
|
|
154
182
|
* @return {OrderLimitOffsetExtract} An object containing orderBy, limit, and offset values if present.
|
|
155
183
|
*/
|
|
@@ -64,6 +64,36 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
64
64
|
this._logger = Logging.for(MethodQueryBuilder.name);
|
|
65
65
|
return this._logger;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* @description
|
|
69
|
+
* Map of query prefixes to their corresponding actions.
|
|
70
|
+
*/
|
|
71
|
+
static { this.prefixMap = {
|
|
72
|
+
[QueryClause.FIND_BY]: "find",
|
|
73
|
+
[QueryClause.PAGE_BY]: "page",
|
|
74
|
+
[QueryClause.COUNT_BY]: "count",
|
|
75
|
+
[QueryClause.SUM_BY]: "sum",
|
|
76
|
+
[QueryClause.AVG_BY]: "avg",
|
|
77
|
+
[QueryClause.MIN_BY]: "min",
|
|
78
|
+
[QueryClause.MAX_BY]: "max",
|
|
79
|
+
[QueryClause.DISTINCT_BY]: "distinct",
|
|
80
|
+
[QueryClause.GROUP_BY_PREFIX]: "group",
|
|
81
|
+
}; }
|
|
82
|
+
/**
|
|
83
|
+
* @description
|
|
84
|
+
* Determines the action and prefix length from a method name.
|
|
85
|
+
*
|
|
86
|
+
* @param methodName {string} - The repository method name.
|
|
87
|
+
* @return {QueryActionPrefix} | undefined} The action and prefix if found.
|
|
88
|
+
*/
|
|
89
|
+
static getActionFromMethodName(methodName) {
|
|
90
|
+
for (const [prefix, action] of Object.entries(this.prefixMap)) {
|
|
91
|
+
if (methodName.startsWith(prefix)) {
|
|
92
|
+
return { action, prefix };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
67
97
|
/**
|
|
68
98
|
* @description
|
|
69
99
|
* Builds a `QueryAssist` object by parsing a repository method name and values.
|
|
@@ -79,18 +109,25 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
79
109
|
* @return {QueryAssist} A structured query object representing the parsed query.
|
|
80
110
|
*/
|
|
81
111
|
static build(methodName, ...values) {
|
|
82
|
-
|
|
112
|
+
const actionInfo = this.getActionFromMethodName(methodName);
|
|
113
|
+
if (!actionInfo) {
|
|
83
114
|
throw new Error(`Unsupported method ${methodName}`);
|
|
84
115
|
}
|
|
85
|
-
const
|
|
116
|
+
const { action, prefix } = actionInfo;
|
|
117
|
+
// For aggregation methods (count, sum, avg, min, max, distinct), extract the selector field
|
|
118
|
+
let selector;
|
|
119
|
+
if (["count", "sum", "avg", "min", "max", "distinct", "group"].includes(action)) {
|
|
120
|
+
selector = this.extractAggregationSelector(methodName, prefix);
|
|
121
|
+
}
|
|
122
|
+
const core = this.extractCore(methodName, prefix);
|
|
86
123
|
const select = this.extractSelect(methodName);
|
|
87
124
|
const groupBy = this.extractGroupBy(methodName);
|
|
88
|
-
// const orderBy = this.extractOrderBy(methodName);
|
|
89
125
|
const where = this.buildWhere(core, values);
|
|
90
|
-
const { orderBy, limit, offset } = this.extractOrderLimitOffset(methodName, values);
|
|
126
|
+
const { orderBy, limit, offset } = this.extractOrderLimitOffset(methodName, values, core);
|
|
91
127
|
return {
|
|
92
|
-
action
|
|
93
|
-
select
|
|
128
|
+
action,
|
|
129
|
+
select,
|
|
130
|
+
selector,
|
|
94
131
|
where,
|
|
95
132
|
groupBy,
|
|
96
133
|
orderBy,
|
|
@@ -100,27 +137,84 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
100
137
|
}
|
|
101
138
|
/**
|
|
102
139
|
* @description
|
|
103
|
-
* Extracts the
|
|
140
|
+
* Extracts the aggregation selector field from method names like countByAge, sumByPrice.
|
|
141
|
+
*
|
|
142
|
+
* @param methodName {string} - The method name.
|
|
143
|
+
* @param prefix {string} - The prefix to remove.
|
|
144
|
+
* @return {string | undefined} The selector field name.
|
|
145
|
+
*/
|
|
146
|
+
static extractAggregationSelector(methodName, prefix) {
|
|
147
|
+
const afterPrefix = methodName.substring(prefix.length);
|
|
148
|
+
// Find where the selector ends (at next clause keyword, operator, or end)
|
|
149
|
+
// Include ThenBy for groupBy prefix
|
|
150
|
+
const regex = /(And|Or|GroupBy|OrderBy|Select|Limit|Offset|ThenBy)/;
|
|
151
|
+
const match = afterPrefix.match(regex);
|
|
152
|
+
const selectorPart = match
|
|
153
|
+
? afterPrefix.substring(0, match.index)
|
|
154
|
+
: afterPrefix;
|
|
155
|
+
return selectorPart ? lowerFirst(selectorPart) : undefined;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @description
|
|
159
|
+
* Extracts the core part of the method name after the prefix and before any special clauses.
|
|
104
160
|
*
|
|
105
161
|
* @summary
|
|
106
162
|
* Removes prefixes and detects delimiters (`Then`, `OrderBy`, `GroupBy`, `Limit`, `Offset`)
|
|
107
163
|
* to isolate the main conditional part of the query.
|
|
108
164
|
*
|
|
109
165
|
* @param methodName {string} - The method name to parse.
|
|
166
|
+
* @param prefix {string} - The prefix to remove (e.g., "findBy", "countBy").
|
|
110
167
|
*
|
|
111
168
|
* @return {string} The extracted core string used for building conditions.
|
|
112
169
|
*/
|
|
113
|
-
static extractCore(methodName) {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
170
|
+
static extractCore(methodName, prefix = QueryClause.FIND_BY) {
|
|
171
|
+
const afterPrefix = methodName.substring(prefix.length);
|
|
172
|
+
// For aggregation methods (not findBy or pageBy), we need to skip the selector field
|
|
173
|
+
const isAggregationPrefix = prefix !== QueryClause.FIND_BY && prefix !== QueryClause.PAGE_BY;
|
|
174
|
+
if (isAggregationPrefix) {
|
|
175
|
+
// For aggregation methods, we need to find where actual conditions start
|
|
176
|
+
// Conditions are indicated by And|Or AFTER the selector field
|
|
177
|
+
// For "countByAgeAndNameEquals", conditions start at "AndNameEquals"
|
|
178
|
+
// For "sumByPriceGroupByCategory", there are no conditions
|
|
179
|
+
// First, identify the selector field boundary
|
|
180
|
+
// The selector ends at: And, Or, GroupBy, OrderBy, ThenBy, Select, Limit, Offset
|
|
181
|
+
const selectorEndMatch = afterPrefix.match(/(And|Or|GroupBy|OrderBy|ThenBy|Select|Limit|Offset)/);
|
|
182
|
+
if (!selectorEndMatch) {
|
|
183
|
+
// No delimiter found, entire suffix is the selector, no conditions
|
|
184
|
+
return "";
|
|
185
|
+
}
|
|
186
|
+
// Check if the first delimiter is And or Or (indicating a condition)
|
|
187
|
+
if (selectorEndMatch[0] === "And" || selectorEndMatch[0] === "Or") {
|
|
188
|
+
// Extract everything AFTER the And/Or (skip the And/Or itself for the first condition)
|
|
189
|
+
const afterAndOr = afterPrefix.substring(selectorEndMatch.index + selectorEndMatch[0].length);
|
|
190
|
+
// Now apply standard delimiter extraction
|
|
191
|
+
const delimiterMatch = afterAndOr.match(/(Then[A-Z]|OrderBy|GroupBy|Limit|Offset|Select|ThenBy)/);
|
|
192
|
+
return delimiterMatch
|
|
193
|
+
? afterAndOr.substring(0, delimiterMatch.index)
|
|
194
|
+
: afterAndOr;
|
|
195
|
+
}
|
|
196
|
+
// First delimiter is not And/Or, so there are no conditions
|
|
197
|
+
return "";
|
|
198
|
+
}
|
|
199
|
+
// For findBy and pageBy, extract core normally
|
|
200
|
+
const regex = /(Then[A-Z]|OrderBy|GroupBy|Limit|Offset|Select)/;
|
|
201
|
+
const match = afterPrefix.match(regex);
|
|
202
|
+
const corePart = match
|
|
203
|
+
? afterPrefix.substring(0, match.index)
|
|
204
|
+
: afterPrefix;
|
|
205
|
+
return corePart;
|
|
118
206
|
}
|
|
119
207
|
static getFieldsFromMethodName(methodName) {
|
|
120
|
-
const
|
|
208
|
+
const actionInfo = this.getActionFromMethodName(methodName);
|
|
209
|
+
const prefix = actionInfo?.prefix || QueryClause.FIND_BY;
|
|
210
|
+
const core = this.extractCore(methodName, prefix);
|
|
211
|
+
if (!core)
|
|
212
|
+
return [];
|
|
121
213
|
const parts = core.split(/OrderBy|GroupBy/)[0] || "";
|
|
122
214
|
const conditions = parts.split(/And|Or/);
|
|
123
|
-
return conditions
|
|
215
|
+
return conditions
|
|
216
|
+
.filter((token) => token.length > 0)
|
|
217
|
+
.map((token) => {
|
|
124
218
|
const { operator, field } = this.parseFieldAndOperator(token);
|
|
125
219
|
return field + (operator ?? "");
|
|
126
220
|
});
|
|
@@ -162,15 +256,38 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
162
256
|
* @return {string[] | undefined} An array of group by fields or `undefined` if no group by clause exists.
|
|
163
257
|
*/
|
|
164
258
|
static extractGroupBy(methodName) {
|
|
259
|
+
// First check for the standard "GroupBy" clause (e.g., findByActiveGroupByCountry)
|
|
165
260
|
const groupByIndex = methodName.indexOf(QueryClause.GROUP_BY);
|
|
166
|
-
if (groupByIndex
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
261
|
+
if (groupByIndex !== -1) {
|
|
262
|
+
const after = methodName.substring(groupByIndex + QueryClause.GROUP_BY.length);
|
|
263
|
+
const groupByPart = after.split(QueryClause.ORDER_BY)[0];
|
|
264
|
+
return groupByPart
|
|
265
|
+
.split(QueryClause.THEN_BY)
|
|
266
|
+
.map(lowerFirst)
|
|
267
|
+
.filter(Boolean);
|
|
268
|
+
}
|
|
269
|
+
// For "groupBy" prefix (e.g., groupByCategoryThenByRegion),
|
|
270
|
+
// extract ThenBy fields after the selector
|
|
271
|
+
const actionInfo = this.getActionFromMethodName(methodName);
|
|
272
|
+
if (actionInfo?.action === "group") {
|
|
273
|
+
const afterPrefix = methodName.substring(actionInfo.prefix.length);
|
|
274
|
+
const thenByIndex = afterPrefix.indexOf(QueryClause.THEN_BY);
|
|
275
|
+
if (thenByIndex === -1)
|
|
276
|
+
return undefined;
|
|
277
|
+
const afterThenBy = afterPrefix.substring(thenByIndex + QueryClause.THEN_BY.length);
|
|
278
|
+
// Split by ThenBy to get multiple group fields
|
|
279
|
+
const parts = afterThenBy.split(QueryClause.THEN_BY);
|
|
280
|
+
// Also stop at OrderBy, Limit, Offset
|
|
281
|
+
const result = [];
|
|
282
|
+
for (const part of parts) {
|
|
283
|
+
const match = part.match(/(OrderBy|Limit|Offset|Select)/);
|
|
284
|
+
const field = match ? part.substring(0, match.index) : part;
|
|
285
|
+
if (field)
|
|
286
|
+
result.push(lowerFirst(field));
|
|
287
|
+
}
|
|
288
|
+
return result.length > 0 ? result : undefined;
|
|
289
|
+
}
|
|
290
|
+
return undefined;
|
|
174
291
|
}
|
|
175
292
|
// private static extractOrderBy(
|
|
176
293
|
// methodName: string
|
|
@@ -209,10 +326,15 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
209
326
|
* @return {Condition<any>} A structured condition object representing the query's where clause.
|
|
210
327
|
*/
|
|
211
328
|
static buildWhere(core, values) {
|
|
212
|
-
|
|
329
|
+
// Empty core means no where conditions
|
|
330
|
+
if (!core)
|
|
213
331
|
return undefined;
|
|
214
332
|
const parts = core.split(/OrderBy|GroupBy/)[0] || "";
|
|
215
|
-
|
|
333
|
+
if (!parts)
|
|
334
|
+
return undefined;
|
|
335
|
+
const conditions = parts.split(/And|Or/).filter((c) => c.length > 0);
|
|
336
|
+
if (conditions.length === 0)
|
|
337
|
+
return undefined;
|
|
216
338
|
const operators = core.match(/And|Or/g) || [];
|
|
217
339
|
let where;
|
|
218
340
|
conditions.forEach((token, idx) => {
|
|
@@ -232,10 +354,6 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
232
354
|
? where.and(condition)
|
|
233
355
|
: where.or(condition);
|
|
234
356
|
});
|
|
235
|
-
if (conditions.length === 0)
|
|
236
|
-
return undefined;
|
|
237
|
-
if (!where)
|
|
238
|
-
throw new Error("No conditions found in method name");
|
|
239
357
|
return where;
|
|
240
358
|
}
|
|
241
359
|
/**
|
|
@@ -294,14 +412,17 @@ export class MethodQueryBuilder extends LoggedClass {
|
|
|
294
412
|
* Determines the number of condition arguments, then checks the remaining arguments
|
|
295
413
|
* to resolve sorting, limiting, and pagination.
|
|
296
414
|
*
|
|
297
|
-
* @param methodName {string} - The
|
|
415
|
+
* @param methodName {string} - The method name.
|
|
298
416
|
* @param values {any[]} - The values corresponding to method arguments, including conditions and extras.
|
|
417
|
+
* @param core {string} - The pre-extracted core string.
|
|
299
418
|
*
|
|
300
419
|
* @return {OrderLimitOffsetExtract} An object containing orderBy, limit, and offset values if present.
|
|
301
420
|
*/
|
|
302
|
-
static extractOrderLimitOffset(methodName, values) {
|
|
303
|
-
const
|
|
304
|
-
const conditionCount =
|
|
421
|
+
static extractOrderLimitOffset(methodName, values, core) {
|
|
422
|
+
const coreString = core ?? this.extractCore(methodName);
|
|
423
|
+
const conditionCount = coreString
|
|
424
|
+
? coreString.split(/And|Or/).filter((s) => s.length > 0).length
|
|
425
|
+
: 0;
|
|
305
426
|
const extraArgs = values.slice(conditionCount) ?? [];
|
|
306
427
|
let orderBy;
|
|
307
428
|
let limit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MethodQueryBuilder.js","sourceRoot":"","sources":["../../../src/query/MethodQueryBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,WAAW,GACZ,mBAAgB;AACjB,OAAO,EAAE,YAAY,EAAE,mBAAgB;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAU,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,qCAAgC;AACzD,OAAO,EAAE,UAAU,EAAE,oBAAiB;AAEtC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE,CACzC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAGvC,MAAM,KAAK,GAAG;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,O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C,CAAC;YAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;YACnD,OAAO,GAAG,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,QAAQ;YAC3D,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAEvB,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,QAAQ;YAC3D,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAExB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC"}
|
|
@@ -91,7 +91,13 @@ export class Statement extends ContextualLoggedClass {
|
|
|
91
91
|
const forceSimple = ctx.get("forcePrepareSimpleQueries");
|
|
92
92
|
const forceComplex = ctx.get("forcePrepareComplexQueries");
|
|
93
93
|
log.silly(`statement force simple ${forceSimple}, forceComplex: ${forceComplex}`);
|
|
94
|
-
|
|
94
|
+
// Simple queries or simple aggregation queries (aggregations without where conditions)
|
|
95
|
+
// Also exclude multi-level groupBy from simple aggregation squashing
|
|
96
|
+
const isSimpleAggregation = this.hasAggregation() &&
|
|
97
|
+
!this.whereCondition &&
|
|
98
|
+
!this.selectSelector?.length &&
|
|
99
|
+
(this.groupBySelectors?.length || 0) <= 1;
|
|
100
|
+
if ((forceSimple && (this.isSimpleQuery() || isSimpleAggregation)) || forceComplex) {
|
|
95
101
|
log.silly(`squashing ${!forceComplex ? "simple" : "complex"} query to prepared statement`);
|
|
96
102
|
await this.prepare(ctx);
|
|
97
103
|
log.silly(`squashed ${!forceComplex ? "simple" : "complex"} query to ${JSON.stringify(this.prepared, null, 2)}`);
|
|
@@ -335,6 +341,78 @@ export class Statement extends ContextualLoggedClass {
|
|
|
335
341
|
}
|
|
336
342
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
337
343
|
squash(ctx) {
|
|
344
|
+
// If there's a where condition with complex conditions (nested Conditions), can't squash
|
|
345
|
+
if (this.whereCondition) {
|
|
346
|
+
if (this.whereCondition["comparison"] instanceof Condition)
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
// Try to squash simple aggregation queries without where conditions
|
|
350
|
+
if (!this.whereCondition && !this.selectSelector?.length) {
|
|
351
|
+
// Count query
|
|
352
|
+
if (typeof this.countSelector !== "undefined" && !this.countDistinctSelector) {
|
|
353
|
+
return {
|
|
354
|
+
class: this.fromSelector,
|
|
355
|
+
method: PreparedStatementKeys.COUNT_OF,
|
|
356
|
+
args: this.countSelector !== null ? [this.countSelector] : [],
|
|
357
|
+
params: {},
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
// Max query
|
|
361
|
+
if (this.maxSelector) {
|
|
362
|
+
return {
|
|
363
|
+
class: this.fromSelector,
|
|
364
|
+
method: PreparedStatementKeys.MAX_OF,
|
|
365
|
+
args: [this.maxSelector],
|
|
366
|
+
params: {},
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
// Min query
|
|
370
|
+
if (this.minSelector) {
|
|
371
|
+
return {
|
|
372
|
+
class: this.fromSelector,
|
|
373
|
+
method: PreparedStatementKeys.MIN_OF,
|
|
374
|
+
args: [this.minSelector],
|
|
375
|
+
params: {},
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
// Avg query
|
|
379
|
+
if (this.avgSelector) {
|
|
380
|
+
return {
|
|
381
|
+
class: this.fromSelector,
|
|
382
|
+
method: PreparedStatementKeys.AVG_OF,
|
|
383
|
+
args: [this.avgSelector],
|
|
384
|
+
params: {},
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
// Sum query
|
|
388
|
+
if (this.sumSelector) {
|
|
389
|
+
return {
|
|
390
|
+
class: this.fromSelector,
|
|
391
|
+
method: PreparedStatementKeys.SUM_OF,
|
|
392
|
+
args: [this.sumSelector],
|
|
393
|
+
params: {},
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
// Distinct query
|
|
397
|
+
if (this.distinctSelector) {
|
|
398
|
+
return {
|
|
399
|
+
class: this.fromSelector,
|
|
400
|
+
method: PreparedStatementKeys.DISTINCT_OF,
|
|
401
|
+
args: [this.distinctSelector],
|
|
402
|
+
params: {},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
// Group by query (simple single-level grouping)
|
|
406
|
+
if (this.groupBySelectors?.length === 1) {
|
|
407
|
+
return {
|
|
408
|
+
class: this.fromSelector,
|
|
409
|
+
method: PreparedStatementKeys.GROUP_OF,
|
|
410
|
+
args: [this.groupBySelectors[0]],
|
|
411
|
+
params: {},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// Can't squash complex queries with select/groupBy/aggregations that have where conditions
|
|
338
416
|
if (this.selectSelector && this.selectSelector.length)
|
|
339
417
|
return undefined;
|
|
340
418
|
if (this.groupBySelectors && this.groupBySelectors.length)
|
|
@@ -353,9 +431,6 @@ export class Statement extends ContextualLoggedClass {
|
|
|
353
431
|
return undefined;
|
|
354
432
|
let attrFromWhere;
|
|
355
433
|
if (this.whereCondition) {
|
|
356
|
-
// if (this.orderBySelector) return undefined;
|
|
357
|
-
if (this.whereCondition["comparison"] instanceof Condition)
|
|
358
|
-
return undefined;
|
|
359
434
|
attrFromWhere = this.whereCondition["attr1"];
|
|
360
435
|
}
|
|
361
436
|
const order = this.orderBySelectors?.[0]
|
|
@@ -401,6 +476,14 @@ export class Statement extends ContextualLoggedClass {
|
|
|
401
476
|
return this;
|
|
402
477
|
}
|
|
403
478
|
}
|
|
479
|
+
// Also try to squash aggregation queries
|
|
480
|
+
if (ctx.get("forcePrepareSimpleQueries") || ctx.get("forcePrepareComplexQueries")) {
|
|
481
|
+
const squashed = this.squash(ctx);
|
|
482
|
+
if (squashed) {
|
|
483
|
+
this.prepared = squashed;
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
404
487
|
const args = [];
|
|
405
488
|
const params = {};
|
|
406
489
|
const prepared = {
|
|
@@ -408,7 +491,45 @@ export class Statement extends ContextualLoggedClass {
|
|
|
408
491
|
args,
|
|
409
492
|
params,
|
|
410
493
|
};
|
|
411
|
-
|
|
494
|
+
// Determine the method prefix based on the query type
|
|
495
|
+
let methodPrefix = QueryClause.FIND_BY;
|
|
496
|
+
let selectorField;
|
|
497
|
+
if (typeof this.countSelector !== "undefined") {
|
|
498
|
+
methodPrefix = QueryClause.COUNT_BY;
|
|
499
|
+
selectorField = this.countSelector !== null ? this.countSelector : undefined;
|
|
500
|
+
}
|
|
501
|
+
else if (this.sumSelector) {
|
|
502
|
+
methodPrefix = QueryClause.SUM_BY;
|
|
503
|
+
selectorField = this.sumSelector;
|
|
504
|
+
}
|
|
505
|
+
else if (this.avgSelector) {
|
|
506
|
+
methodPrefix = QueryClause.AVG_BY;
|
|
507
|
+
selectorField = this.avgSelector;
|
|
508
|
+
}
|
|
509
|
+
else if (this.minSelector) {
|
|
510
|
+
methodPrefix = QueryClause.MIN_BY;
|
|
511
|
+
selectorField = this.minSelector;
|
|
512
|
+
}
|
|
513
|
+
else if (this.maxSelector) {
|
|
514
|
+
methodPrefix = QueryClause.MAX_BY;
|
|
515
|
+
selectorField = this.maxSelector;
|
|
516
|
+
}
|
|
517
|
+
else if (this.distinctSelector) {
|
|
518
|
+
methodPrefix = QueryClause.DISTINCT_BY;
|
|
519
|
+
selectorField = this.distinctSelector;
|
|
520
|
+
}
|
|
521
|
+
else if (this.groupBySelectors?.length &&
|
|
522
|
+
!this.selectSelector?.length &&
|
|
523
|
+
!this.whereCondition) {
|
|
524
|
+
// Group-only query (no select, no where)
|
|
525
|
+
methodPrefix = QueryClause.GROUP_BY_PREFIX;
|
|
526
|
+
selectorField = this.groupBySelectors[0];
|
|
527
|
+
}
|
|
528
|
+
// If there's a where condition or selectSelector, use findBy prefix even with groupBy
|
|
529
|
+
const method = [methodPrefix];
|
|
530
|
+
if (selectorField) {
|
|
531
|
+
method.push(selectorField);
|
|
532
|
+
}
|
|
412
533
|
if (this.whereCondition) {
|
|
413
534
|
const parsed = this.prepareCondition(this.whereCondition, ctx);
|
|
414
535
|
method.push(parsed.method);
|
|
@@ -428,11 +549,17 @@ export class Statement extends ContextualLoggedClass {
|
|
|
428
549
|
});
|
|
429
550
|
}
|
|
430
551
|
}
|
|
431
|
-
|
|
552
|
+
// Handle groupBy for non-aggregation queries (already handled for group prefix)
|
|
553
|
+
if (this.groupBySelectors?.length && methodPrefix !== QueryClause.GROUP_BY_PREFIX) {
|
|
432
554
|
const [primary, ...rest] = this.groupBySelectors;
|
|
433
555
|
method.push(QueryClause.GROUP_BY, primary);
|
|
434
556
|
rest.forEach((attr) => method.push(QueryClause.THEN_BY, attr));
|
|
435
557
|
}
|
|
558
|
+
else if (this.groupBySelectors?.length && methodPrefix === QueryClause.GROUP_BY_PREFIX) {
|
|
559
|
+
// For group prefix, add additional group fields as ThenBy
|
|
560
|
+
const rest = this.groupBySelectors.slice(1);
|
|
561
|
+
rest.forEach((attr) => method.push(QueryClause.THEN_BY, attr));
|
|
562
|
+
}
|
|
436
563
|
if (this.limitSelector)
|
|
437
564
|
params.limit = this.limitSelector;
|
|
438
565
|
if (this.offsetSelector) {
|
|
@@ -451,7 +578,8 @@ export class Statement extends ContextualLoggedClass {
|
|
|
451
578
|
this.maxSelector ||
|
|
452
579
|
this.minSelector ||
|
|
453
580
|
this.sumSelector ||
|
|
454
|
-
this.avgSelector
|
|
581
|
+
this.avgSelector ||
|
|
582
|
+
this.distinctSelector);
|
|
455
583
|
}
|
|
456
584
|
hasAggregation() {
|
|
457
585
|
return (typeof this.countSelector !== "undefined" ||
|