SqlReplication: Fix T-SQL string escaping#2445
Conversation
WalkthroughAdds two private SQL-escaping helpers (ConvertTo-SqlString, ConvertTo-EscapedQueryString), updates DSC_SqlReplication's Install-RemoteDistributor to use escaped values for SQL Server 2025, and adds Pester unit tests for the new utilities and escaping behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 8-20: Condense the three “Added” bullets into two items by merging
the two SqlServerDsc entries: replace the separate bullets for
ConvertTo-SqlString and ConvertTo-EscapedQueryString with a single SqlServerDsc
entry that briefly notes both private helper functions (ConvertTo-SqlString and
ConvertTo-EscapedQueryString) were added to safely escape T-SQL string literals
and query arguments, and keep the SqlReplication entry for
Install-RemoteDistributor as the second item mentioning it now escapes T-SQL
arguments for SQL Server 2025; ensure wording is concise and follows the ≤2
items per change type rule.
In `@source/Private/ConvertTo-EscapedQueryString.ps1`:
- Around line 38-41: Update the comment-based help in
ConvertTo-EscapedQueryString.ps1 so each OUTPUTS entry lists the return type as
inline code (e.g., `System.String`) followed by a one-line description, and
apply this change to both occurrences (around the shown block and lines 66-69);
also rename the short loop variable `$arg` to a descriptive name of 3+
characters (for example `$argument` or `$item`) throughout the
ConvertTo-EscapedQueryString function and any related loops/blocks to comply
with the naming guideline.
In `@source/Private/ConvertTo-SqlString.ps1`:
- Around line 38-41: The .OUTPUTS section in the comment-based help for
ConvertTo-SqlString is using a plain type token; update the .OUTPUTS block so
the return type is formatted as inline code (e.g., surround the type with inline
code markers) and keep a one-line description stating "Returns the escaped
string with single quotes doubled." Ensure the .OUTPUTS entry is a single-line
with the inline-coded type followed by the short description to match the help
formatting rules.
… enhancements to Install-RemoteDistributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2445 +/- ##
=====================================
- Coverage 94% 94% -1%
=====================================
Files 225 227 +2
Lines 10769 10778 +9
=====================================
+ Hits 10142 10149 +7
- Misses 627 629 +2
🚀 New features to boost your workflow:
|
Pull Request (PR) description
ConvertTo-SqlStringto escape strings for T-SQL literals.ConvertTo-EscapedQueryStringto format queries with escaped arguments.Install-RemoteDistributorto utilize these functions for escaping T-SQL arguments.This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is