Skip to content

Commit 1f4538e

Browse files
committed
fixing readastext
1 parent 816aa83 commit 1f4538e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

functions/Invoke-DBOQuery.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,7 @@ function Invoke-DBOQuery {
369369
for ($j = 1; -not $name; $j++) {
370370
if ($table.Columns.ColumnName -notcontains "Column$j") { $name = "Column$j" }
371371
}
372-
if ($datatype.FullName -eq 'System.DBNull') {
373-
$datatype = [string]
374-
}
375-
elseif (!$datatype.FullName) {
372+
if ($ReturnAsText -or $datatype.FullName -eq 'System.DBNull' -or -not $datatype.FullName) {
376373
$datatype = [string]
377374
}
378375
$null = $table.Columns.Add($name, $datatype)

tests/postgresql/Invoke-DBOQuery.Tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,12 @@ Describe "Invoke-DBOQuery PostgreSQL tests" -Tag $commandName, IntegrationTests
179179
$result.b | Should -Be 3, 4
180180
}
181181
It "should select an unsupported datatype as text" {
182-
$query = "select cast(null as aclitem[]) as a, cast('{=c/postgres}' as aclitem[]) as b"
182+
$query = "select cast(null as aclitem[]) as a, cast('{=c/postgres}' as aclitem[]) as b, E'\\001'::bytea as c"
183183
$result = Invoke-DBOQuery -Query $query @connParams -As DataTable -ReturnAsText
184-
$result.Columns.ColumnName | Should -Be @('a', 'b')
184+
$result.Columns.ColumnName | Should -Be @('a', 'b', 'c')
185185
$result.a | Should -Be ([System.DBNull]::Value)
186186
$result.b | Should -Be '{=c/postgres}'
187+
$result.c | Should -Be '\x01'
187188
}
188189
}
189190
Context "Negative tests" {

0 commit comments

Comments
 (0)