fix(channel): remove duplicated pushName alias and prefer Contact.pushName in fetchChats#2460
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRemoves a redundant selection of the pushName field from a channel query so that the value computed earlier in the query is no longer incorrectly overridden with Chat.name, preventing null/incorrect pushName results. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Hi! As part of our PR triage, we re-ran CI on this PR and the Check Code Quality workflow is failing. Could you please:
Once CI is green I'll re-review for merge. Thanks! |
Hello, but the lint errors are not in the files I changed. |
DavidsonGomes
left a comment
There was a problem hiding this comment.
Fix correto — a query fetchChats em Postgres tinha dois aliases pushName no SELECT (o CASE e "Chat"."name" as "pushName"), e Postgres retornava ambas as colunas com o driver podendo sobrescrever silenciosamente uma pela outra. Remover é a coisa certa.
LGTM com pedidos pequenos antes do merge:
-
Título do PR é enganoso — não é remoção de "campo não usado"; é correção de duplicação de alias + ajuste do
COALESCE. Sugestão:fix(channel): remove duplicated pushName alias and prefer Contact.pushName in fetchChats. -
Replicar no SQL MySQL — o mesmo arquivo tem ramo MySQL (acima no
if (dbProvider === 'mysql')) que não foi tocado. Para evitar divergência PG/MySQL, aplicar o mesmo ajuste lá.
Consideração sobre o ELSE do CASE: para chats 1:1, a mudança remove o fallback de Message.pushName. Se Contact.pushName for null (contato nunca sincronizado), o cliente exibirá vazio onde antes mostrava o nome do remetente da última mensagem. Probabilidade baixa, mas vale anotar — se quiser preservar fallback em 1:1, manter o COALESCE no ELSE e remover apenas a duplicação do alias resolve.
Feito ✔️ |
📋 Description
This PR updates the chat listing query to ensure that the
pushNamealways reflects the contact’s name, not the name from the last message sender.Previously, in the PostgreSQL
fetchChatsquery, thepushNamefor non-group chats was calculated usingCOALESCE("Contact"."pushName", "Message"."pushName"). This could lead to incorrect results: when the last message was sent by someone else (e.g., in a multi-participant context), thepushNamewould show the sender’s name instead of the contact’s name. The query has been updated so that, for non-group chats,pushNamenow uses only"Contact"."pushName", preventing it from being overridden by"Message"."pushName"and ensuring consistent, contact-based naming.🔗 Related Issue
Closes #(issue_number)
🧪 Type of Change
🧪 Testing
Testing details:
pushName, but instead correctly show the contact’spushName.Contact.pushNamekeep the same visible name.📸 Screenshots (if applicable)
✅ Checklist
📝 Additional Notes
pushNamebehavior with the expectation that it always represents the contact’s name in chat lists, avoiding confusion when the last message is sent by someone else.