Add SQL builder utilities for PostgreSQL replication management#64
Add SQL builder utilities for PostgreSQL replication management#64
Conversation
- Introduced a new module `sql_builder` containing functions for building SQL statements related to replication slots and subscriptions. - Implemented quoting functions for identifiers and string literals to prevent SQL injection. - Added SQL builders for creating, altering, dropping, and managing replication slots and subscriptions. - Included tests for all new functionalities to ensure correctness and prevent regressions. - update SQL generation for START_REPLICATION to remove unnecessary parentheses and add null byte checks in quoting functions - simplify SQL command construction in sql_builder.rs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64 +/- ##
==========================================
+ Coverage 93.74% 94.40% +0.65%
==========================================
Files 10 11 +1
Lines 14364 15251 +887
==========================================
+ Hits 13466 14398 +932
+ Misses 898 853 -45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request centralizes SQL building logic into a new sql_builder module, replacing duplicated sanitization and quoting helpers across the libpq and native connection implementations. The refactoring improves safety by introducing null byte checks and standardizing identifier and literal quoting. Consequently, several methods that previously returned String have been updated to return Result<String> to accommodate potential configuration errors. Feedback was provided regarding the redefinition of a constant that is already available in the types module.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized sql_builder module to handle the construction of PostgreSQL replication protocol commands. It refactors the libpq and native connection implementations to delegate SQL generation to this new module, replacing duplicated sanitization and quoting logic. The new implementation includes enhanced security checks, such as null byte validation for identifiers and literals, and provides a suite of unit tests for the builder functions. I have no feedback to provide.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request centralizes SQL command construction for PostgreSQL replication by introducing a new sql_builder module. It refactors both the libpq and native connection implementations to utilize these shared utilities, replacing internal sanitization and quoting functions. The new implementation enhances security by explicitly checking for and rejecting null bytes in SQL identifiers and literals. Consequently, several internal SQL building methods now return a Result<String> instead of a plain String. I have no feedback to provide as there are no review comments.
sql_buildercontaining functions for building SQL statements related to replication slots and subscriptions.