Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clp: Add support for SQLite prepared select statement. #402

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

LinZhihao-723
Copy link
Member

@LinZhihao-723 LinZhihao-723 commented May 14, 2024

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.

@LinZhihao-723
Copy link
Member Author

The refactoring lgtm

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.

2 participants