discussion: how to build dynamic SQL queries
Context
As part of Add ability to perform backward pagination in L... (#1012 - closed) and noted in !1323 (comment 1429976048), we had to modify certain SQL queries based on the filters
input when the method is called.
Problem
Currently, there is a simple if/else condition and some string formatting doing the job. However, this can get messy as we continue building on top of these queries.
Solution
Consider using libraries that would allow us to write queries more dynamically.
Some points to consider:
- Research popular libraries, e.g. https://github.com/Masterminds/squirrel
- Make sure it plays nicely with our pg driver/client (https://github.com/jackc/pgx)
- Ensure they are simple to use with the
stdlib
without further dependencies