Skip to content

Build your personal knowledge base with Trilium Notes

fixed false sync error reporting

azivneraf529f82e508
diff --git a/src/services/content_hash.js b/src/services/content_hash.js
index dd1f508b4d..9cb568a895 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 = "";