Skip to content

Commit

Permalink
adding support for underscore char in tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
nvarscar committed Jan 29, 2022
1 parent 7f49d8b commit 961a686
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/functions/Resolve-VariableToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
foreach ($obj in $InputObject) {
if ($obj -is [string]) {
$output = $obj
foreach ($token in (Get-VariableToken -InputString $obj -RegexString $TokenRegex.Replace('token', '[a-zA-Z0-9\-.]+'))) {
foreach ($token in (Get-VariableToken -InputString $obj -RegexString $TokenRegex.Replace('token', '[a-zA-Z0-9_\-.]+'))) {
#Replace variables found in the config
$tokenRegExString = $TokenRegex.Replace('token', [Regex]::Escape($token))
if ($Runtime) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Invoke-DBOQuery.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ Describe "Invoke-DBOQuery tests" -Tag $commandName, IntegrationTests {
}
It "should run the query with custom variables and custom token template" {
Set-PSFConfig -FullName dbops.config.variabletoken -Value '\$(token)\$'
$query = "SELECT '`$Test`$' AS A, '`$Test2`$' AS B UNION ALL SELECT '3' AS A, '4' AS B"
$result = Invoke-DBOQuery -Query $query -SqlInstance $script:mssqlInstance -Credential $script:mssqlCredential -As DataTable -Variables @{ Test = '1'; Test2 = '2' }
$query = "SELECT '`$Test`$' AS A, '`$Test_2.1-3`$' AS B UNION ALL SELECT '3' AS A, '4' AS B"
$result = Invoke-DBOQuery -Query $query -SqlInstance $script:mssqlInstance -Credential $script:mssqlCredential -As DataTable -Variables @{ Test = '1'; "Test_2.1-3" = '2' }
$result.A | Should -Be '1', '3'
$result.B | Should -Be '2', '4'
(Get-PSFConfig -FullName dbops.config.variabletoken).ResetValue()
Expand Down

0 comments on commit 961a686

Please sign in to comment.