rez_core 5.0.110 → 5.0.112

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": "rez_core",
3
- "version": "5.0.110",
3
+ "version": "5.0.112",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -780,7 +780,10 @@ export class FilterService {
780
780
  // Force every param to be a string
781
781
  if (clause.params) {
782
782
  Object.keys(clause.params).forEach((k) => {
783
- clause.params[k] = String(clause.params[k]);
783
+ const val = clause.params[k];
784
+ if (!Array.isArray(val)) {
785
+ clause.params[k] = String(val); // only convert scalar values
786
+ }
784
787
  });
785
788
  }
786
789
 
@@ -1222,65 +1225,54 @@ export class FilterService {
1222
1225
  }
1223
1226
  }
1224
1227
 
1225
- private buildMultiSelectCondition(
1226
- attr: string,
1227
- op: string,
1228
- val: any,
1229
- key: string,
1230
- ) {
1231
- // Convert value to array ALWAYS
1232
- let arr: any[] = [];
1228
+ private buildMultiSelectCondition(attr: string, op: string, val: any, key: string) {
1229
+ let arr: string[] = [];
1233
1230
 
1231
+ // SAFETY: Convert all to array
1234
1232
  if (Array.isArray(val)) {
1235
- arr = val.map((v) => String(v));
1233
+ arr = val.map(v => String(v));
1236
1234
  } else if (typeof val === 'string') {
1237
- // convert "345,346" ["345", "346"]
1238
- arr = val.split(',').map((v) => v.trim());
1235
+ arr = val.split(',').map(v => v.trim());
1239
1236
  } else {
1240
- throw new BadRequestException(`Invalid multiselect value for ${attr}`);
1237
+ throw new BadRequestException(`Invalid multiselect value`);
1241
1238
  }
1242
1239
 
1243
- // Prevent empty IN ()
1244
1240
  if (arr.length === 0) {
1245
1241
  return { query: '1=1', params: {} };
1246
1242
  }
1247
1243
 
1248
- switch (op) {
1249
- case 'equal':
1250
- return {
1251
- query: `e.${attr}::text IN (:...${key})`,
1252
- params: { [key]: arr },
1253
- };
1254
-
1255
- case 'not_equal':
1256
- return {
1257
- query: `e.${attr}::text NOT IN (:...${key})`,
1258
- params: { [key]: arr },
1259
- };
1244
+ if (op === 'equal') {
1245
+ return {
1246
+ query: `e.${attr}::text IN (:...${key})`,
1247
+ params: { [key]: arr },
1248
+ };
1249
+ }
1260
1250
 
1261
- case 'contains':
1262
- return {
1263
- query: `e.${attr}::text LIKE :${key}`,
1264
- params: { [key]: `%${val}%` },
1265
- };
1251
+ if (op === 'not_equal') {
1252
+ return {
1253
+ query: `e.${attr}::text NOT IN (:...${key})`,
1254
+ params: { [key]: arr },
1255
+ };
1256
+ }
1266
1257
 
1267
- case 'not_contains':
1268
- return {
1269
- query: `e.${attr}::text NOT LIKE :${key}`,
1270
- params: { [key]: `%${val}%` },
1271
- };
1258
+ if (op === 'contains') {
1259
+ return {
1260
+ query: `e.${attr}::text LIKE :${key}`,
1261
+ params: { [key]: `%${val}%` },
1262
+ };
1263
+ }
1272
1264
 
1273
- case 'empty':
1274
- return { query: `e.${attr} IS NULL`, params: {} };
1265
+ if (op === 'not_contains') {
1266
+ return {
1267
+ query: `e.${attr}::text NOT LIKE :${key}`,
1268
+ params: { [key]: `%${val}%` },
1269
+ };
1270
+ }
1275
1271
 
1276
- case 'not_empty':
1277
- return { query: `e.${attr} IS NOT NULL`, params: {} };
1272
+ if (op === 'empty') return { query: `e.${attr} IS NULL`, params: {} };
1273
+ if (op === 'not_empty') return { query: `e.${attr} IS NOT NULL`, params: {} };
1278
1274
 
1279
- default:
1280
- throw new BadRequestException(
1281
- `Unsupported operator for multiselect: ${op}`,
1282
- );
1283
- }
1275
+ throw new BadRequestException(`Unsupported operator: ${op}`);
1284
1276
  }
1285
1277
 
1286
1278
  private buildYearCondition(attr: string, op: string, val: any, key: string) {