Skip to content

Commit

Permalink
Conversation last message/activity: Use IS/IS NOT to better handle NULL
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Nonnenberg <scott@signal.org>
  • Loading branch information
automated-signal and scottnonnenberg-signal committed Nov 19, 2021
1 parent 4c30e27 commit 96909cd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ts/sql/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2450,11 +2450,11 @@ function getLastConversationActivity({
json_extract(json, '$.expirationTimerUpdate.fromSync') != 1
) AND NOT
(
type = 'group-v2-change' AND
json_extract(json, '$.groupV2Change.from') != $ourUuid AND
json_extract(json, '$.groupV2Change.details.length') = 1 AND
json_extract(json, '$.groupV2Change.details[0].type') = 'member-remove' AND
json_extract(json, '$.groupV2Change.details[0].uuid') != $ourUuid
type IS 'group-v2-change' AND
json_extract(json, '$.groupV2Change.from') IS NOT $ourUuid AND
json_extract(json, '$.groupV2Change.details.length') IS 1 AND
json_extract(json, '$.groupV2Change.details[0].type') IS 'member-remove' AND
json_extract(json, '$.groupV2Change.details[0].uuid') IS NOT $ourUuid
)
ORDER BY received_at DESC, sent_at DESC
LIMIT 1;
Expand Down Expand Up @@ -2501,11 +2501,11 @@ function getLastConversationPreview({
)
) AND NOT
(
type = 'group-v2-change' AND
json_extract(json, '$.groupV2Change.from') != $ourUuid AND
json_extract(json, '$.groupV2Change.details.length') = 1 AND
json_extract(json, '$.groupV2Change.details[0].type') = 'member-remove' AND
json_extract(json, '$.groupV2Change.details[0].uuid') != $ourUuid
type IS 'group-v2-change' AND
json_extract(json, '$.groupV2Change.from') IS NOT $ourUuid AND
json_extract(json, '$.groupV2Change.details.length') IS 1 AND
json_extract(json, '$.groupV2Change.details[0].type') IS 'member-remove' AND
json_extract(json, '$.groupV2Change.details[0].uuid') IS NOT $ourUuid
)
ORDER BY received_at DESC, sent_at DESC
LIMIT 1;
Expand Down

0 comments on commit 96909cd

Please sign in to comment.