The query running previously was
SELECT id, title, plain_text, created_at FROM Notes WHERE deleted != 1 and author_id = '17d8af20-6054-11ee-be82-b1b190fc05e2' or author_id = 'guest_user_id' ORDER BY created_at DESC'
This will select the notes even for which deleted is set to 1, because the operator precedence is wrong.
Fix
Changed the query and added brackets around author_id condition for precendency.
Now the query becomes:
SELECT id, title, plain_text, created_at FROM Notes WHERE deleted != 1 and (author_id = '17d8af20-6054-11ee-be82-b1b190fc05e2' or author_id = 'guest_user_id') ORDER BY created_at DESC'
Hey sorry I forgot to add hacktoberfest tag before merging. Let me know if it is not counted in your hacktoberfest PR's, we can revert and re-merge this
What type of PR is this? (check all applicable)
Description/ RCA
The query used to fetch the notes was wrong.
The query running previously was SELECT id, title, plain_text, created_at FROM Notes WHERE deleted != 1 and author_id = '17d8af20-6054-11ee-be82-b1b190fc05e2' or author_id = 'guest_user_id' ORDER BY created_at DESC' This will select the notes even for which deleted is set to 1, because the operator precedence is wrong.
Fix
Changed the query and added brackets around author_id condition for precendency. Now the query becomes:
SELECT id, title, plain_text, created_at FROM Notes WHERE deleted != 1 and (author_id = '17d8af20-6054-11ee-be82-b1b190fc05e2' or author_id = 'guest_user_id') ORDER BY created_at DESC'
Related Tickets & Documents
Tested Feature??
@SankethBK could you please review it