From af529f82e5080f01b26ac7db104a8041f137dc48 Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 2 Jun 2018 09:39:04 -0400 Subject: [PATCH] fixed false sync error reporting --- src/services/content_hash.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/content_hash.js b/src/services/content_hash.js index dd1f508b4..9cb568a89 100644 --- a/src/services/content_hash.js +++ b/src/services/content_hash.js @@ -16,8 +16,11 @@ const RecentNote = require('../entities/recent_note'); const Option = require('../entities/option'); async function getHash(entityConstructor, whereBranch) { - let contentToHash = await sql.getValue(`SELECT GROUP_CONCAT(hash) FROM ${entityConstructor.tableName} ` - + (whereBranch ? `WHERE ${whereBranch} ` : '') + `ORDER BY ${entityConstructor.primaryKeyName}`); + // subselect is necessary to have correct ordering in GROUP_CONCAT + const query = `SELECT GROUP_CONCAT(hash) FROM (SELECT hash FROM ${entityConstructor.tableName} ` + + (whereBranch ? `WHERE ${whereBranch} ` : '') + `ORDER BY ${entityConstructor.primaryKeyName})`; + + let contentToHash = await sql.getValue(query); if (!contentToHash) { // might be null in case of no rows contentToHash = "";