@nest-omni/core 4.1.3-6 → 4.1.3-8

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": "@nest-omni/core",
3
- "version": "4.1.3-6",
3
+ "version": "4.1.3-8",
4
4
  "description": "A comprehensive NestJS framework for building enterprise-grade applications with best practices",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -92,24 +92,22 @@ let IsUniqueValidator = class IsUniqueValidator {
92
92
  let exists;
93
93
  const defCon = findCondition(args);
94
94
  // 获取用于判断是否为新建的字段
95
- // 优先使用手动配置的 uniqueKeys,否则使用主键
95
+ // 优先级:手动配置的 uniqueKeys > 实体主键
96
96
  let pkCols;
97
- const hasUniqueKeys = (options === null || options === void 0 ? void 0 : options.uniqueKeys) && options.uniqueKeys.length > 0;
98
- if (hasUniqueKeys) {
99
- // 使用手动指定的字段
97
+ if ((options === null || options === void 0 ? void 0 : options.uniqueKeys) && options.uniqueKeys.length > 0) {
98
+ // 1. 使用手动指定的字段
100
99
  pkCols = options.uniqueKeys;
101
100
  }
102
101
  else {
103
- // 使用实体的主键
102
+ // 2. 使用实体的主键
104
103
  pkCols = repository.metadata
105
104
  .primaryColumns.map((column) => column.propertyName);
106
105
  }
107
106
  // 如果没有主键也没有 uniqueKeys,使用简化逻辑
108
- // 查询条件本身就能表示唯一性:0-1条允许,2条及以上不允许
107
+ // 查询条件本身表示唯一性,只要存在记录就不允许
109
108
  if (pkCols.length === 0) {
110
109
  const count = yield repository.count({ where: defCon });
111
- // 0条(不存在)或1条(认为是自己)都允许,2条及以上不允许
112
- exists = count <= 1;
110
+ exists = count < 1;
113
111
  return exists;
114
112
  }
115
113
  // 修复:检查是否为新建记录