clp
clp copied to clipboard
clp: Add support for SQLite prepared select statement.
References
Description
Before this PR, SQLIte prepared select statements are manually written using a format string, making it hard to get column values using a selected column name: there is no built-in way to track the column indices.
This PR implements a class to wrap SQLIte prepared select statement. It takes the column names to select, the table name to select from, and an "AND chaining" WHERE
clause + an ORDER
clause. This class maintains an internal mapping of the column indices so the caller can get column values by providing a column name.
The filters in the WHERE
clause and the ORDER
clause are formatted by the caller. The caller will take care of value binding using proper placeholders.
Validation performed
- Replaced the manually generated select statement by the new class in the existing unit test; using column names to get the column values directly.
- Added new unit test to cover filtering.
- Workflow passed.