Skip to content

Conversation

@vijay2909
Copy link

Fixes: #99

All instances of database.rawQuery() that involved dynamic arguments have been converted to use the structured database.query() builder.

This change eliminates manual SQL string concatenation, which is a common source of bugs and security vulnerabilities. By using parameterized queries (? placeholders), we now fully protect against SQL injection.

Some Cursor objects are now initialized within try-with-resources blocks. This guarantees that every cursor is automatically and correctly closed, even if an exception is thrown during processing. This prevents Cursor leaks, which can lead to app instability and crashes.

@TheLastProject
Copy link
Member

Looks pretty good on first look, will have to look a bit more deeply as this is of course very important code to be bug-free.

We have several open MRs (also one from you) touching the database class right now though. Like #2716 and #2731. I am thinking the following review/merge order would be best:

  1. Refactor(DB): Replace rawQuery with query builder and use try-with-re… #2745 (this one)
  2. Add barcode encoding support #2716 (as it fixes a serious bug)
  3. feat: Add time selection to date picker with ISO datetime storage #2731

Would you agree with that order of review/merge? It does mean you'd either have to rebase #2731 twice or wait for #2716 to be done before you can rebase that one, I hope that's okay.

@vijay2909
Copy link
Author

Thanks for the thoughtful review and for planning out the merge strategy!

The proposed order sounds perfect. I'll keep an eye on the other PRs and get #2731 rebased once they're merged. No problem at all.

Let me know if anything else is needed on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor SQL

3 participants