orange-dragonfly-model 0.11.1 → 0.11.2
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/components/model.js +3 -3
- package/package.json +1 -1
package/components/model.js
CHANGED
|
@@ -169,9 +169,9 @@ class Model extends ORM.ActiveRecord {
|
|
|
169
169
|
/**
|
|
170
170
|
* Checks uniqueness of the object based on UNIQUE_KEYS
|
|
171
171
|
*/
|
|
172
|
-
async checkUniqueness (exception_mode = false) {
|
|
172
|
+
async checkUniqueness (exception_mode = false, ignore_null = false) {
|
|
173
173
|
for (const fields of this.constructor.UNIQUE_KEYS) {
|
|
174
|
-
if (!await this.isUnique(fields)) {
|
|
174
|
+
if (!await this.isUnique(fields, ignore_null)) {
|
|
175
175
|
if (exception_mode) {
|
|
176
176
|
const ex = new ValidationException('Object is not unique')
|
|
177
177
|
for (const field of fields) {
|
|
@@ -193,7 +193,7 @@ class Model extends ORM.ActiveRecord {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
await super._preSave()
|
|
196
|
-
await this.checkUniqueness(true)
|
|
196
|
+
await this.checkUniqueness(true, true)
|
|
197
197
|
await this.validate()
|
|
198
198
|
}
|
|
199
199
|
|