Skip to content

Commit 9ca7dd3

Browse files
author
Kirill Kravtsov
committed
Removing native dbUp variable replacement
1 parent 86bf147 commit 9ca7dd3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

functions/Invoke-DBODeployment.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@
173173
$comparer = [DBOpsScriptComparer]::new($scriptCollection.Name)
174174
$dbUp = [StandardExtensions]::WithScriptNameComparer($dbUp, $comparer)
175175

176+
# Disable variable replacement
177+
$dbUp = [StandardExtensions]::WithVariablesDisabled($dbUp)
178+
176179
if ($config.DeploymentMethod -eq 'SingleTransaction') {
177180
$dbUp = [StandardExtensions]::WithTransaction($dbUp)
178181
}

tests/postgresql/Install-DBOSqlScript.Tests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ Describe "Install-DBOSqlScript PostgreSQL integration tests" -Tag $commandName,
267267
$output | Should BeLike '*Successful!*'
268268
}
269269
}
270+
Context "testing var replacement" {
271+
BeforeAll {
272+
$file = "$workFolder\vars.sql"
273+
'SELECT ''$a$'';' | Set-Content $file
274+
}
275+
BeforeEach {
276+
$null = Invoke-DBOQuery @connParams -Database postgres -Query $dropDatabaseScript
277+
[Npgsql.NpgsqlConnection]::ClearAllPools()
278+
$null = Invoke-DBOQuery @connParams -Database postgres -Query $createDatabaseScript
279+
}
280+
It "should not fail to read the script" {
281+
$null = Install-DBOSqlScript -Absolute -Type PostgreSQL -ScriptPath "$workFolder\vars.sql" -SqlInstance $script:postgresqlInstance -Credential $script:postgresqlCredential -Database $newDbName -SchemaVersionTable $logTable -OutputFile "$workFolder\log.txt" -Silent
282+
$output = Get-Content "$workFolder\log.txt" -Raw
283+
$output | Should BeLike '*$a$*'
284+
}
285+
}
270286
Context "$commandName whatif tests" {
271287
BeforeAll {
272288
$null = Invoke-DBOQuery @connParams -Database postgres -Query $dropDatabaseScript

0 commit comments

Comments
 (0)