From 5c247fc73ddd47c3fb7e65390b1fd031bbbc6252 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 25 May 2020 23:09:45 +0300 Subject: [PATCH] Fix for error with thread message number increment on MySQL --- src/data/Thread.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/Thread.js b/src/data/Thread.js index ab9898d..960b567 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -250,9 +250,9 @@ class Thread { * @private */ _lastMessageNumberInThreadSQL() { - return knex('thread_messages') - .select(knex.raw('MAX(message_number)')) - .whereRaw(`thread_messages.thread_id = '${this.id}'`) + return knex('thread_messages AS tm_msg_num_ref') + .select(knex.raw('MAX(tm_msg_num_ref.message_number)')) + .whereRaw(`tm_msg_num_ref.thread_id = '${this.id}'`) .toSQL() .sql; }