rez_core 4.0.147 → 4.0.151

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": "4.0.147",
3
+ "version": "4.0.151",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -37,6 +37,7 @@ export class FilterService {
37
37
 
38
38
  let whereSQL = '';
39
39
  const values: any[] = [];
40
+ let paramIndex = 1; // PostgreSQL placeholders start at $1
40
41
 
41
42
  if (whereClauses.length > 0) {
42
43
  const clauseParts = whereClauses.map((clause) => {
@@ -44,15 +45,26 @@ export class FilterService {
44
45
 
45
46
  Object.entries(clause.params).forEach(([key, val]) => {
46
47
  if (Array.isArray(val)) {
47
- // if it's an array → expand placeholders (?, ?, ?)
48
- const placeholders = val.map(() => '?').join(', ');
48
+ // Create ($1,$2,$3)
49
+ const placeholders = val
50
+ .map(() => `$${paramIndex++}`)
51
+ .join(', ');
52
+
49
53
  parsedQuery = parsedQuery.replace(
50
54
  new RegExp(`:${key}`, 'g'),
51
55
  `(${placeholders})`,
52
56
  );
53
- values.push(...val); // flatten values
57
+
58
+ values.push(...val);
54
59
  } else {
55
- parsedQuery = parsedQuery.replace(new RegExp(`:${key}`, 'g'), '?');
60
+ // Create $1
61
+ const placeholder = `$${paramIndex++}`;
62
+
63
+ parsedQuery = parsedQuery.replace(
64
+ new RegExp(`:${key}`, 'g'),
65
+ placeholder,
66
+ );
67
+
56
68
  values.push(val);
57
69
  }
58
70
  });
@@ -64,11 +76,11 @@ export class FilterService {
64
76
  }
65
77
 
66
78
  const rawSQL = `
67
- SELECT ${column} AS tab_value, COUNT(*) AS tab_value_count
68
- FROM ${tableName}
69
- ${whereSQL}
70
- GROUP BY ${column}
71
- `;
79
+ SELECT ${column} AS tab_value, COUNT(*) AS tab_value_count
80
+ FROM ${tableName}
81
+ ${whereSQL}
82
+ GROUP BY ${column}
83
+ `;
72
84
 
73
85
  const rows = await this.dataSource.query(rawSQL, values);
74
86
 
@@ -466,6 +478,11 @@ export class FilterService {
466
478
  const size = dto.size && dto.size > 0 ? dto.size : 10;
467
479
  qb.skip((page - 1) * size).take(size);
468
480
 
481
+ let query = await qb.getQuery();
482
+
483
+ console.log('------------------------------------------------------\n')
484
+ console.log(query);
485
+ console.log('\n------------------------------------------------------')
469
486
  const entity_list = await qb.getRawMany();
470
487
 
471
488
  console.log(`📦 [FilterService] Fetched ${entity_list.length} records`);