SankethBK / diaryvault

A personal diary application written in Flutter
https://play.google.com/store/apps/details?id=me.sankethbk.dairyapp
MIT License
91 stars 58 forks source link

[Binni] Fix. save note not working after delete (#38) #47

Closed droidbg closed 11 months ago

droidbg commented 11 months ago

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

SankethBK commented 11 months ago

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

droidbg commented 11 months ago

@SankethBK it is counted, Thanks.