rez_core 4.0.64 → 4.0.65
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
|
@@ -36,7 +36,6 @@ export class FilterService {
|
|
|
36
36
|
) {
|
|
37
37
|
if (!column) return [];
|
|
38
38
|
|
|
39
|
-
// Basic SQL injection protection for identifiers
|
|
40
39
|
if (!/^[a-zA-Z0-9_]+$/.test(tableName) || !/^[a-zA-Z0-9_]+$/.test(column)) {
|
|
41
40
|
throw new Error('Invalid table or column name');
|
|
42
41
|
}
|
|
@@ -46,46 +45,19 @@ export class FilterService {
|
|
|
46
45
|
|
|
47
46
|
if (whereClauses.length > 0) {
|
|
48
47
|
const clauseParts = whereClauses.map((clause) => {
|
|
49
|
-
// remove alias 'e.'
|
|
50
48
|
let parsedQuery = clause.query.replace(/\be\./g, '');
|
|
51
|
-
|
|
52
49
|
Object.entries(clause.params).forEach(([key, val]) => {
|
|
53
50
|
if (Array.isArray(val)) {
|
|
54
|
-
// Always use IN operator for arrays
|
|
55
51
|
const placeholders = val.map(() => '?').join(', ');
|
|
56
|
-
|
|
57
|
-
if (parsedQuery.match(new RegExp(`=\\s*:${key}\\b`))) {
|
|
58
|
-
parsedQuery = parsedQuery.replace(
|
|
59
|
-
new RegExp(`=\\s*:${key}\\b`, 'g'),
|
|
60
|
-
`IN (${placeholders})`,
|
|
61
|
-
);
|
|
62
|
-
} else {
|
|
63
|
-
parsedQuery = parsedQuery.replace(
|
|
64
|
-
new RegExp(`:\\b${key}\\b`, 'g'),
|
|
65
|
-
`(${placeholders})`,
|
|
66
|
-
);
|
|
67
|
-
// add IN keyword if not already there
|
|
68
|
-
if (!parsedQuery.includes('IN')) {
|
|
69
|
-
parsedQuery = parsedQuery.replace(
|
|
70
|
-
new RegExp(`(${placeholders})`),
|
|
71
|
-
`IN $1`,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
52
|
+
parsedQuery = parsedQuery.replace(new RegExp(`:${key}\\b`, 'g'), placeholders);
|
|
75
53
|
values.push(...val);
|
|
76
54
|
} else {
|
|
77
|
-
parsedQuery = parsedQuery.replace(
|
|
78
|
-
new RegExp(`:\\b${key}\\b`, 'g'),
|
|
79
|
-
'?',
|
|
80
|
-
);
|
|
55
|
+
parsedQuery = parsedQuery.replace(new RegExp(`:${key}\\b`, 'g'), '?');
|
|
81
56
|
values.push(val);
|
|
82
57
|
}
|
|
83
58
|
});
|
|
84
|
-
|
|
85
|
-
// group safely
|
|
86
59
|
return `(${parsedQuery})`;
|
|
87
60
|
});
|
|
88
|
-
|
|
89
61
|
whereSQL = `WHERE ${clauseParts.join(' AND ')}`;
|
|
90
62
|
}
|
|
91
63
|
|
|
@@ -96,20 +68,7 @@ export class FilterService {
|
|
|
96
68
|
GROUP BY ${column}
|
|
97
69
|
`;
|
|
98
70
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const total = rows.reduce(
|
|
102
|
-
(sum, r) => sum + Number(r.tab_value_count || 0),
|
|
103
|
-
0,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return [
|
|
107
|
-
{ tab_value: 'All', tab_value_count: total },
|
|
108
|
-
...rows.map((r) => ({
|
|
109
|
-
tab_value: r.tab_value ?? 'UNKNOWN',
|
|
110
|
-
tab_value_count: Number(r.tab_value_count || 0),
|
|
111
|
-
})),
|
|
112
|
-
];
|
|
71
|
+
return await this.dataSource.query(rawSQL, values);
|
|
113
72
|
}
|
|
114
73
|
|
|
115
74
|
|