Skip to content

Commit 5e39ebc

Browse files
authored
Merge pull request #116 from sqlcollaborative/development
v0.6.4
2 parents 816aa83 + bd041d8 commit 5e39ebc

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Release notes for v0.6.4:
2+
- ### Forcing the string datatype onto columns when -ReturnAsText is used (#115) by @nvarscar
13
# Release notes for v0.6.3:
24
- ### Adding hyphen to the variable token symbols (#112) by @nvarscar
35
# Release notes for v0.6.2:

functions/Invoke-DBOQuery.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function Invoke-DBOQuery {
7575
Specifies output type. Valid options for this parameter are 'DataSet', 'DataTable', 'DataRow', 'PSObject', and 'SingleValue'
7676
7777
.PARAMETER ReturnAsText
78-
Postgres only: returns all fields of the dataset as text values. This helps with the datatypes that are unknown to npgsql.
78+
Converts all fields of the dataset to a string datatype. This helps with the datatypes that are unknown to connectivity libraries and can't be automatically converted.
7979
8080
.PARAMETER Parameter
8181
Uses values in specified hashtable as parameters inside the SQL query.
@@ -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)