diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.js index 27cad3f26..f3f98fe5c 100644 --- a/src/becca/entities/bnote.js +++ b/src/becca/entities/bnote.js @@ -1156,14 +1156,8 @@ class BNote extends AbstractBeccaEntity { /** @returns {BAttachment} */ getAttachmentByTitle(title) { - return sql.getRows(` - SELECT attachments.* - FROM attachments - WHERE ownerId = ? - AND title = ? - AND isDeleted = 0 - ORDER BY position`, [this.noteId, title]) - .map(row => new BAttachment(row))[0]; + // cannot use SQL to filter by title since it can be encrypted + return this.getAttachments().filter(attachment => attachment.title === title)[0]; } /** diff --git a/src/becca/entities/brevision.js b/src/becca/entities/brevision.js index 09a78db64..de9bfbd82 100644 --- a/src/becca/entities/brevision.js +++ b/src/becca/entities/brevision.js @@ -157,14 +157,8 @@ class BRevision extends AbstractBeccaEntity { /** @returns {BAttachment} */ getAttachmentByTitle(title) { - return sql.getRows(` - SELECT attachments.* - FROM attachments - WHERE ownerId = ? - AND title = ? - AND isDeleted = 0 - ORDER BY position`, [this.revisionId, title]) - .map(row => new BAttachment(row))[0]; + // cannot use SQL to filter by title since it can be encrypted + return this.getAttachments().filter(attachment => attachment.title === title)[0]; } beforeSaving() {