Skip to content

Commit bda2cdd

Browse files
committed
escape dollar sign for sequelize error
1 parent 81561fa commit bda2cdd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

electron_app/src/database/DBEmanager.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ const deleteEmailsByThreadIdAndLabelId = (threadIds, labelId) => {
286286
: `${systemLabels.spam.id}, ${systemLabels.trash.id}`;
287287
return Email().destroy({
288288
where: {
289-
threadId: threadIds,
289+
threadId: parseSpecialCharacters(threadIds),
290290
[Op.and]: [
291291
getDB().literal(
292292
`exists (select * from EmailLabel where Email.id = EmailLabel.emailId AND EmailLabel.labelId IN (${labelIdsToDelete}))`
@@ -855,9 +855,14 @@ const updateEmails = ({ ids, keys, unread, trashDate }, trx) => {
855855
const updateUnreadEmailByThreadIds = ({ threadIds, unread }) => {
856856
const params = {};
857857
if (typeof unread === 'boolean') params.unread = unread;
858-
return Email().update(params, { where: { threadId: threadIds } });
858+
return Email().update(params, {
859+
where: { threadId: parseSpecialCharacters(threadIds) }
860+
});
859861
};
860862

863+
const parseSpecialCharacters = array =>
864+
array.map(element => element.replace(/\$/g, '$$$$'));
865+
861866
/* EmailContact
862867
----------------------------- */
863868
const createEmailContact = (emailContacts, trx) => {

0 commit comments

Comments
 (0)