mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix undeleting note when its relation points to yet-undeleted note
This commit is contained in:
parent
a888f9aa04
commit
64e7150765
@ -80,14 +80,14 @@ class AbstractBeccaEntity {
|
|||||||
*
|
*
|
||||||
* @returns {this}
|
* @returns {this}
|
||||||
*/
|
*/
|
||||||
save() {
|
save(opts = {}) {
|
||||||
const entityName = this.constructor.entityName;
|
const entityName = this.constructor.entityName;
|
||||||
const primaryKeyName = this.constructor.primaryKeyName;
|
const primaryKeyName = this.constructor.primaryKeyName;
|
||||||
|
|
||||||
const isNewEntity = !this[primaryKeyName];
|
const isNewEntity = !this[primaryKeyName];
|
||||||
|
|
||||||
if (this.beforeSaving) {
|
if (this.beforeSaving) {
|
||||||
this.beforeSaving();
|
this.beforeSaving(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pojo = this.getPojoToSave();
|
const pojo = this.getPojoToSave();
|
||||||
|
@ -176,8 +176,10 @@ class BAttribute extends AbstractBeccaEntity {
|
|||||||
return !(this.attributeId in this.becca.attributes);
|
return !(this.attributeId in this.becca.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeSaving() {
|
beforeSaving(opts = {}) {
|
||||||
this.validate();
|
if (!opts.skipValidation) {
|
||||||
|
this.validate();
|
||||||
|
}
|
||||||
|
|
||||||
this.name = sanitizeAttributeName(this.name);
|
this.name = sanitizeAttributeName(this.name);
|
||||||
|
|
||||||
|
@ -670,7 +670,8 @@ function undeleteBranch(branchId, deleteId, taskContext) {
|
|||||||
OR (type = 'relation' AND value = ?))`, [deleteId, note.noteId, note.noteId]);
|
OR (type = 'relation' AND value = ?))`, [deleteId, note.noteId, note.noteId]);
|
||||||
|
|
||||||
for (const attribute of attributes) {
|
for (const attribute of attributes) {
|
||||||
new BAttribute(attribute).save();
|
// relation might point to a note which hasn't been undeleted yet and would thus throw up
|
||||||
|
new BAttribute(attribute).save({skipValidation: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
const noteAttachments = sql.getRows(`
|
const noteAttachments = sql.getRows(`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user