discourse/plugins
Alan Guo Xiang Tan 9c39053d6f
FIX: Ensure order when moving chat messages to another channel (#21447)
What is the problem?

Previously, this was the query used to move change messages into another
channel.

```
INSERT INTO chat_messages(
  chat_channel_id, user_id, last_editor_id, message, cooked, cooked_version, created_at, updated_at
)
SELECT :destination_channel_id,
        user_id,
        last_editor_id,
        message,
        cooked,
        cooked_version,
        CLOCK_TIMESTAMP(),
        CLOCK_TIMESTAMP()
FROM chat_messages
WHERE id IN (:message_ids)
RETURNING id
```

The problem is that this incorrectly assumes that the insertion will be based on the order of `message_ids`. However, that
is not the case as PostgreSQL provides no such guarantee. Instead we need to explicitly order the messages to ensure
the right order of insertion.

This problem was discovered by a flaky test which exposed the non-guarantee order of insertion.
2023-05-09 10:37:12 +08:00
..
chat FIX: Ensure order when moving chat messages to another channel (#21447) 2023-05-09 10:37:12 +08:00
discourse-details Update translations (#21055) 2023-04-11 15:45:03 +02:00
discourse-lazy-videos FIX: Remove double escaped Vimeo titles (#21368) 2023-05-04 07:54:00 -03:00
discourse-local-dates DEV: Support @debounce decorator in native class syntax (#20521) 2023-03-03 11:48:58 +00:00
discourse-narrative-bot Update translations (#21145) 2023-04-25 17:23:21 +02:00
discourse-presence Update translations (#20370) 2023-02-20 11:01:01 +01:00
poll Update translations (#21334) 2023-05-02 17:39:33 +02:00
styleguide Update translations (#21145) 2023-04-25 17:23:21 +02:00