@@ -23,10 +23,10 @@ if (-not (Test-DBOSupportedSystem -Type Oracle)) {
23
23
24
24
$newDbName = ' test_dbops_invokedboquery'
25
25
$connParams = @ {
26
- SqlInstance = $script :oracleInstance
27
- Credential = $script :oracleCredential
28
- Type = ' Oracle'
29
- Silent = $true
26
+ SqlInstance = $script :oracleInstance
27
+ Credential = $script :oracleCredential
28
+ Type = ' Oracle'
29
+ Silent = $true
30
30
ConnectionAttribute = @ {
31
31
' DBA Privilege' = ' SYSDBA'
32
32
}
@@ -37,7 +37,7 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
37
37
It " should run the query" {
38
38
$query = " SELECT 1 AS A, 2 AS B FROM DUAL UNION ALL SELECT NULL AS A, 4 AS B FROM DUAL"
39
39
$result = Invoke-DBOQuery - Query $query @connParams -As DataTable
40
- $result.Columns.ColumnName | Should - Be @ (' A' , ' B' )
40
+ $result.Columns.ColumnName | Should - Be @ (' A' , ' B' )
41
41
$result.A | Should - Be 1 , ([DBNull ]::Value)
42
42
$result.B | Should - Be 2 , 4
43
43
}
@@ -47,23 +47,24 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
47
47
$result.Columns.ColumnName | Should - Be @ (' NULL' )
48
48
$result.NULL | Should - Be ([DBNull ]::Value)
49
49
}
50
- It " should run the query with semicolon" {
51
- $query = " SELECT 1 AS A, 2 AS B FROM DUAL;
50
+ It " should run the query with a slash" {
51
+ $query = " SELECT 1 AS A, 2 AS B FROM DUAL
52
+ /
52
53
SELECT 3 AS A, 4 AS B FROM DUAL"
53
54
$result = Invoke-DBOQuery - Query $query @connParams -As DataTable
54
- $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
55
- $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
55
+ $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
56
+ $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
56
57
$result [0 ].A | Should - Be 1
57
58
$result [0 ].B | Should - Be 2
58
59
$result [1 ].A | Should - Be 3
59
60
$result [1 ].B | Should - Be 4
60
61
}
61
- It " should run the query with semicolon as a dataset" {
62
- $query = " SELECT 1 AS A, 2 AS B FROM DUAL;
62
+ It " should run the query with a slash as a dataset" {
63
+ $query = " SELECT 1 AS A, 2 AS B FROM DUAL/
63
64
SELECT 3 AS A, 4 AS B FROM DUAL"
64
65
$result = Invoke-DBOQuery - Query $query @connParams -As Dataset
65
- $result.Tables [0 ].Columns.ColumnName | Should Be @ (' A' , ' B' )
66
- $result.Tables [1 ].Columns.ColumnName | Should Be @ (' A' , ' B' )
66
+ $result.Tables [0 ].Columns.ColumnName | Should Be @ (' A' , ' B' )
67
+ $result.Tables [1 ].Columns.ColumnName | Should Be @ (' A' , ' B' )
67
68
$result.Tables [0 ].A | Should - Be 1
68
69
$result.Tables [0 ].B | Should - Be 2
69
70
$result.Tables [1 ].A | Should - Be 3
@@ -72,7 +73,7 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
72
73
It " should run the query as a PSObject" {
73
74
$query = " SELECT 1 AS A, 2 AS B FROM DUAL UNION ALL SELECT NULL AS A, 4 AS B FROM DUAL"
74
75
$result = Invoke-DBOQuery - Query $query @connParams -As PSObject
75
- $result [0 ].psobject.properties.Name | Should - Be @ (' A' , ' B' )
76
+ $result [0 ].psobject.properties.Name | Should - Be @ (' A' , ' B' )
76
77
$result.A | Should - Be 1 , $null
77
78
$result.B | Should - Be 2 , 4
78
79
}
@@ -87,8 +88,8 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
87
88
" SELECT 1 AS A, 2 AS B FROM DUAL" | Out-File $file1 - Force
88
89
" SELECT 3 AS A, 4 AS B FROM DUAL" | Out-File $file2 - Force - Encoding bigendianunicode
89
90
$result = Invoke-DBOQuery - InputFile $file1 , $file2 @connParams -As DataTable
90
- $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
91
- $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
91
+ $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
92
+ $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
92
93
$result [0 ].A | Should - Be 1
93
94
$result [0 ].B | Should - Be 2
94
95
$result [1 ].A | Should - Be 3
@@ -100,24 +101,24 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
100
101
" SELECT 1 AS A, 2 AS B FROM DUAL" | Out-File $file1 - Force
101
102
" SELECT 3 AS A, 4 AS B FROM DUAL" | Out-File $file2 - Force - Encoding bigendianunicode
102
103
$result = Get-Item $file1 , $file2 | Invoke-DBOQuery @connParams -As DataTable
103
- $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
104
- $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
104
+ $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
105
+ $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
105
106
$result [0 ].A | Should - Be 1
106
107
$result [0 ].B | Should - Be 2
107
108
$result [1 ].A | Should - Be 3
108
109
$result [1 ].B | Should - Be 4
109
110
$result = $file1 , $file2 | Invoke-DBOQuery @connParams -As DataTable
110
- $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
111
- $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
111
+ $result [0 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
112
+ $result [1 ].Columns.ColumnName | Should - Be @ (' A' , ' B' )
112
113
$result [0 ].A | Should - Be 1
113
114
$result [0 ].B | Should - Be 2
114
115
$result [1 ].A | Should - Be 3
115
116
$result [1 ].B | Should - Be 4
116
117
}
117
118
It " should run the query with custom variables" {
118
119
$query = " SELECT '#{Test}' AS A, '#{Test2}' AS B FROM DUAL UNION ALL SELECT '3' AS A, '4' AS B FROM DUAL"
119
- $result = Invoke-DBOQuery - Query $query @connParams -As DataTable - Variables @ { Test = ' 1' ; Test2 = ' 2' }
120
- $result.Columns.ColumnName | Should - Be @ (' A' , ' B' )
120
+ $result = Invoke-DBOQuery - Query $query @connParams -As DataTable - Variables @ { Test = ' 1' ; Test2 = ' 2' }
121
+ $result.Columns.ColumnName | Should - Be @ (' A' , ' B' )
121
122
$result.A | Should - Be ' 1' , ' 3'
122
123
$result.B | Should - Be ' 2' , ' 4'
123
124
}
@@ -126,13 +127,13 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
126
127
$result = Invoke-DBOQuery - Type Oracle - Query $query - SqlInstance ' #{srv}' - Credential $script :oracleCredential -As DataTable - Variables @ { srv = $script :oracleInstance } - ConnectionAttribute @ {
127
128
' DBA Privilege' = ' SYSDBA'
128
129
}
129
- $result.Columns.ColumnName | Should - Be @ (' A' , ' B' )
130
+ $result.Columns.ColumnName | Should - Be @ (' A' , ' B' )
130
131
$result.A | Should - Be ' 1' , ' 3'
131
132
$result.B | Should - Be ' 2' , ' 4'
132
133
}
133
134
It " should run the query with custom parameters" {
134
135
$query = " SELECT :p1 AS A, :p2 AS B FROM DUAL"
135
- $result = Invoke-DBOQuery - Query $query @connParams - Parameter @ { p1 = ' 1' ; p2 = ' string' }
136
+ $result = Invoke-DBOQuery - Query $query @connParams - Parameter @ { p1 = ' 1' ; p2 = ' string' }
136
137
$result.A | Should - Be 1
137
138
$result.B | Should - Be string
138
139
}
@@ -152,16 +153,16 @@ Describe "Invoke-DBOQuery Oracle tests" -Tag $commandName, IntegrationTests {
152
153
}
153
154
It " should throw a connection timeout error" {
154
155
$query = " SELECT 1/0 FROM DUAL"
155
- try { $null = Invoke-DBOQuery - Type Oracle - Query $query - SqlInstance localhost:6493 - Credential $script :oracleCredential - ConnectionTimeout 1 }
156
+ try { $null = Invoke-DBOQuery - Type Oracle - Query $query - SqlInstance localhost:6493 - Credential $script :oracleCredential - ConnectionTimeout 1 }
156
157
catch { $errVar = $_ }
157
158
$errVar.Exception.Message | Should -Match " Connection request timed out"
158
159
}
159
160
It " should fail when credentials are wrong" {
160
161
try { Invoke-DBOQuery - Type Oracle - Query ' SELECT 1 FROM DUAL' - SqlInstance $script :oracleInstance - Credential ([pscredential ]::new(' nontexistent' , ([securestring ]::new()))) }
161
- catch {$errVar = $_ }
162
+ catch { $errVar = $_ }
162
163
$errVar.Exception.Message | Should -Match ' null password given; logon denied'
163
164
try { Invoke-DBOQuery - Type Oracle - Query ' SELECT 1 FROM DUAL' - SqlInstance $script :oracleInstance - UserName nontexistent - Password (ConvertTo-SecureString ' foo' - AsPlainText - Force) }
164
- catch {$errVar = $_ }
165
+ catch { $errVar = $_ }
165
166
$errVar.Exception.Message | Should -Match ' invalid username/password; logon denied'
166
167
}
167
168
It " should fail when input file is not found" {
0 commit comments