@naturalcycles/db-lib
Advanced tools
Comparing version 8.9.0 to 8.9.1
@@ -0,1 +1,8 @@ | ||
## [8.9.1](https://github.com/NaturalCycles/db-lib/compare/v8.9.0...v8.9.1) (2021-07-22) | ||
### Bug Fixes | ||
* `updated` was wrongly updated on dbm load ([f6e8814](https://github.com/NaturalCycles/db-lib/commit/f6e88146ede51468e107c53648639864d175e274)) | ||
# [8.9.0](https://github.com/NaturalCycles/db-lib/compare/v8.8.0...v8.9.0) (2021-07-04) | ||
@@ -2,0 +9,0 @@ |
@@ -384,5 +384,6 @@ "use strict"; | ||
this.requireWriteAccess(); | ||
const dbm = this.bmToDBM(bm, opt); // does assignIdCreatedUpdated, mutates | ||
const idWasGenerated = !bm.id; | ||
this.assignIdCreatedUpdated(bm, opt); // mutates | ||
const dbm = this.bmToDBM(bm, opt); | ||
const table = opt.table || this.cfg.table; | ||
const idWasGenerated = !bm.id; | ||
if (opt.ensureUniqueId && idWasGenerated) | ||
@@ -442,3 +443,4 @@ await this.ensureUniqueId(table, dbm); | ||
const idWasGenerated = !dbm.id; | ||
dbm = this.anyToDBM(dbm, opt); // does assignIdCreatedUpdated | ||
this.assignIdCreatedUpdated(dbm, opt); // mutates | ||
dbm = this.anyToDBM(dbm, opt); | ||
if (opt.ensureUniqueId && idWasGenerated) | ||
@@ -459,3 +461,4 @@ await this.ensureUniqueId(table, dbm); | ||
const table = opt.table || this.cfg.table; | ||
const dbms = this.bmsToDBM(bms, opt); // does assignIdCreatedUpdated (mutates) | ||
bms.forEach(bm => this.assignIdCreatedUpdated(bm, opt)); | ||
const dbms = this.bmsToDBM(bms, opt); | ||
if (opt.ensureUniqueId) | ||
@@ -479,3 +482,4 @@ throw new js_lib_1.AppError('ensureUniqueId is not supported in saveBatch'); | ||
if (!opt.raw) { | ||
dbms = this.anyToDBMs(dbms, opt); // does assignIdCreatedUpdated | ||
dbms.forEach(dbm => this.assignIdCreatedUpdated(dbm, opt)); // mutates | ||
dbms = this.anyToDBMs(dbms, opt); | ||
if (opt.ensureUniqueId) | ||
@@ -549,4 +553,4 @@ throw new js_lib_1.AppError('ensureUniqueId is not supported in saveBatch'); | ||
// bm = this.validateAndConvert(bm, this.cfg.bmSchema, DBModelType.BM, opt) | ||
// Mutates | ||
this.assignIdCreatedUpdated(bm, opt); | ||
// should not do it on load, but only on save! | ||
// this.assignIdCreatedUpdated(bm, opt) | ||
// BM > DBM | ||
@@ -564,3 +568,4 @@ const dbm = { ...this.cfg.hooks.beforeBMToDBM(bm) }; | ||
return; | ||
this.assignIdCreatedUpdated(dbm, opt); // mutates | ||
// this shouldn't be happening on load! but should on save! | ||
// this.assignIdCreatedUpdated(dbm, opt) | ||
dbm = { ...dbm, ...this.cfg.hooks.parseNaturalId(dbm.id) }; | ||
@@ -639,5 +644,3 @@ if (opt.anonymize) { | ||
// It will still *convert* the value and return. | ||
if (this.cfg.onValidationError) { | ||
this.cfg.onValidationError(error); | ||
} | ||
this.cfg.onValidationError?.(error); | ||
} | ||
@@ -644,0 +647,0 @@ } |
@@ -45,3 +45,3 @@ { | ||
}, | ||
"version": "8.9.0", | ||
"version": "8.9.1", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -48,0 +48,0 @@ "keywords": [ |
@@ -527,5 +527,6 @@ import { | ||
this.requireWriteAccess() | ||
const dbm = this.bmToDBM(bm, opt) // does assignIdCreatedUpdated, mutates | ||
const idWasGenerated = !bm.id | ||
this.assignIdCreatedUpdated(bm, opt) // mutates | ||
const dbm = this.bmToDBM(bm, opt) | ||
const table = opt.table || this.cfg.table | ||
const idWasGenerated = !bm.id | ||
if (opt.ensureUniqueId && idWasGenerated) await this.ensureUniqueId(table, dbm) | ||
@@ -598,3 +599,4 @@ const op = `save(${dbm.id})` | ||
const idWasGenerated = !dbm.id | ||
dbm = this.anyToDBM(dbm, opt) // does assignIdCreatedUpdated | ||
this.assignIdCreatedUpdated(dbm, opt) // mutates | ||
dbm = this.anyToDBM(dbm, opt) | ||
if (opt.ensureUniqueId && idWasGenerated) await this.ensureUniqueId(table, dbm) | ||
@@ -615,3 +617,4 @@ } | ||
const table = opt.table || this.cfg.table | ||
const dbms = this.bmsToDBM(bms, opt) // does assignIdCreatedUpdated (mutates) | ||
bms.forEach(bm => this.assignIdCreatedUpdated(bm, opt)) | ||
const dbms = this.bmsToDBM(bms, opt) | ||
if (opt.ensureUniqueId) throw new AppError('ensureUniqueId is not supported in saveBatch') | ||
@@ -641,3 +644,4 @@ const op = `saveBatch ${dbms.length} row(s) (${_truncate( | ||
if (!opt.raw) { | ||
dbms = this.anyToDBMs(dbms, opt) // does assignIdCreatedUpdated | ||
dbms.forEach(dbm => this.assignIdCreatedUpdated(dbm, opt)) // mutates | ||
dbms = this.anyToDBMs(dbms, opt) | ||
if (opt.ensureUniqueId) throw new AppError('ensureUniqueId is not supported in saveBatch') | ||
@@ -740,4 +744,4 @@ } | ||
// Mutates | ||
this.assignIdCreatedUpdated(bm, opt) | ||
// should not do it on load, but only on save! | ||
// this.assignIdCreatedUpdated(bm, opt) | ||
@@ -761,3 +765,4 @@ // BM > DBM | ||
this.assignIdCreatedUpdated(dbm, opt) // mutates | ||
// this shouldn't be happening on load! but should on save! | ||
// this.assignIdCreatedUpdated(dbm, opt) | ||
@@ -863,5 +868,3 @@ dbm = { ...dbm, ...this.cfg.hooks!.parseNaturalId!(dbm.id) } | ||
// It will still *convert* the value and return. | ||
if (this.cfg.onValidationError) { | ||
this.cfg.onValidationError(error) | ||
} | ||
this.cfg.onValidationError?.(error) | ||
} | ||
@@ -868,0 +871,0 @@ } |
386478
9086