rez_core 1.0.73 → 1.0.74

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": "1.0.73",
3
+ "version": "1.0.74",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -261,7 +261,6 @@ export class MasterService {
261
261
  }
262
262
  }
263
263
  }
264
-
265
264
  async upsertViaService(
266
265
  entityType: string,
267
266
  data: any[],
@@ -278,18 +277,24 @@ export class MasterService {
278
277
  if (!entityService) throw new Error(`Entity service not found for ${entityType}`);
279
278
 
280
279
  for (const row of data) {
281
- const whereClause = uniqueFields.reduce((acc, field) => {
282
- acc[field] = row[field];
283
- return acc;
284
- }, {});
285
-
286
- const existing = await this.entityManager
280
+ const qb = this.entityManager
287
281
  .createQueryBuilder()
288
282
  .select('*')
289
- .from(entityMaster.db_table_name, entityMaster.db_table_name)
290
- .where(whereClause)
291
- .limit(1)
292
- .getRawOne();
283
+ .from(entityMaster.db_table_name, entityMaster.db_table_name);
284
+
285
+ // Build OR conditions dynamically for unique fields
286
+ uniqueFields.forEach((field, index) => {
287
+ const condition = `${entityMaster.db_table_name}.${field} = :val${index}`;
288
+ const param = { [`val${index}`]: row[field] };
289
+
290
+ if (index === 0) {
291
+ qb.where(condition, param);
292
+ } else {
293
+ qb.orWhere(condition, param);
294
+ }
295
+ });
296
+
297
+ const existing = await qb.limit(1).getRawOne();
293
298
 
294
299
  row.entity_type = entityType;
295
300
 
@@ -307,5 +312,6 @@ export class MasterService {
307
312
  }
308
313
 
309
314
 
315
+
310
316
 
311
317
  }