mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: Select correct topic draft for user (#15234)
The old query could return multiple rows.
This commit is contained in:
parent
049bc33838
commit
b1c11d5787
@ -211,7 +211,7 @@ class UserStat < ActiveRecord::Base
|
||||
UPDATE user_stats
|
||||
SET draft_count = (SELECT COUNT(*) FROM drafts WHERE user_id = :user_id)
|
||||
WHERE user_id = :user_id
|
||||
RETURNING draft_count, (SELECT 1 FROM drafts WHERE draft_key = :new_topic)
|
||||
RETURNING draft_count, (SELECT 1 FROM drafts WHERE user_id = :user_id AND draft_key = :new_topic)
|
||||
SQL
|
||||
|
||||
MessageBus.publish(
|
||||
|
@ -179,6 +179,8 @@ describe Draft do
|
||||
end
|
||||
|
||||
it 'updates draft count when a draft is created or destroyed' do
|
||||
Draft.set(Fabricate(:user), Draft::NEW_TOPIC, 0, "data")
|
||||
|
||||
messages = MessageBus.track_publish("/user") do
|
||||
Draft.set(user, Draft::NEW_TOPIC, 0, "data")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user