19
19
* 226. dbType01.js
20
20
*
21
21
* DESCRIPTION
22
- * Test binding data of types DB_TYPE_CHAR, DB_TYPE_NCHAR,
23
- * DB_TYPE_NVARCHAR, DB_TYPE_DATE and DB_TYPE_TIMESTAMP_LTZ.
22
+ * Test binding data of types DB_TYPE_*.
24
23
*
25
24
*****************************************************************************/
26
25
'use strict' ;
27
26
28
27
const oracledb = require ( 'oracledb' ) ;
29
28
const should = require ( 'should' ) ;
30
29
const dbconfig = require ( './dbconfig.js' ) ;
30
+ const testsUtil = require ( './testsUtil.js' ) ;
31
31
32
32
describe ( '226. dbType01.js' , function ( ) {
33
33
34
34
let conn ;
35
+ const default_stmtCacheSize = oracledb . stmtCacheSize ;
35
36
36
37
before ( async ( ) => {
38
+ oracledb . stmtCacheSize = 0 ;
37
39
try {
38
40
conn = await oracledb . getConnection ( dbconfig ) ;
39
41
} catch ( err ) {
@@ -47,17 +49,24 @@ describe('226. dbType01.js', function() {
47
49
} catch ( err ) {
48
50
should . not . exist ( err ) ;
49
51
}
52
+ oracledb . stmtCacheSize = default_stmtCacheSize ;
53
+ } ) ;
54
+
55
+ afterEach ( async ( ) => {
56
+ await testsUtil . sleep ( 100 ) ;
50
57
} ) ;
51
58
52
59
const strInVal = "Node-oracledb" ;
53
60
const dateInVal = new Date ( ) ;
54
- const SQL = `SELECT DUMP(:1) FROM dual` ;
61
+ const numInVal = 12 ;
62
+ const SQL = `SELECT :1, DUMP(:1) FROM dual` ;
55
63
56
64
it ( '226.1 DB_TYPE_VARCHAR' , async ( ) => {
57
65
try {
58
66
const result = await conn . execute ( SQL ,
59
67
[ { val : strInVal , type : oracledb . DB_TYPE_VARCHAR } ] ) ;
60
- ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=1 Len=13' ) ;
68
+ should . strictEqual ( strInVal , result . rows [ 0 ] [ 0 ] ) ;
69
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=1 Len=13' ) ;
61
70
} catch ( err ) {
62
71
should . not . exist ( err ) ;
63
72
}
@@ -67,7 +76,8 @@ describe('226. dbType01.js', function() {
67
76
try {
68
77
const result = await conn . execute ( SQL ,
69
78
[ { val : strInVal , type : oracledb . DB_TYPE_CHAR } ] ) ;
70
- ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=96 Len=13' ) ;
79
+ should . strictEqual ( strInVal , result . rows [ 0 ] [ 0 ] ) ;
80
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=96 Len=13' ) ;
71
81
} catch ( err ) {
72
82
should . not . exist ( err ) ;
73
83
}
@@ -77,7 +87,8 @@ describe('226. dbType01.js', function() {
77
87
try {
78
88
const result = await conn . execute ( SQL ,
79
89
[ { val : strInVal , type : oracledb . DB_TYPE_NVARCHAR } ] ) ;
80
- ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=1 Len=26' ) ;
90
+ should . strictEqual ( strInVal , result . rows [ 0 ] [ 0 ] ) ;
91
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=1 Len=26' ) ;
81
92
} catch ( err ) {
82
93
should . not . exist ( err ) ;
83
94
}
@@ -87,7 +98,8 @@ describe('226. dbType01.js', function() {
87
98
try {
88
99
const result = await conn . execute ( SQL ,
89
100
[ { val : strInVal , type : oracledb . DB_TYPE_NCHAR } ] ) ;
90
- ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=96 Len=26' ) ;
101
+ should . strictEqual ( strInVal , result . rows [ 0 ] [ 0 ] ) ;
102
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=96 Len=26' ) ;
91
103
} catch ( err ) {
92
104
should . not . exist ( err ) ;
93
105
}
@@ -97,7 +109,7 @@ describe('226. dbType01.js', function() {
97
109
try {
98
110
const result = await conn . execute ( SQL ,
99
111
[ { val : dateInVal , type : oracledb . DB_TYPE_DATE } ] ) ;
100
- ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=12 Len=7' ) ;
112
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=12 Len=7' ) ;
101
113
} catch ( err ) {
102
114
should . not . exist ( err ) ;
103
115
}
@@ -107,10 +119,82 @@ describe('226. dbType01.js', function() {
107
119
try {
108
120
const result = await conn . execute ( SQL ,
109
121
[ { val : dateInVal , type : oracledb . DB_TYPE_TIMESTAMP_LTZ } ] ) ;
110
- ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=231 Len=11' ) ;
122
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=231 Len=11' ) ;
111
123
} catch ( err ) {
112
124
should . not . exist ( err ) ;
113
125
}
114
126
} ) ; // 226.6
115
127
116
- } ) ;
128
+ it ( '226.7 DB_TYPE_TIMESTAMP' , async ( ) => {
129
+ try {
130
+ const result = await conn . execute ( SQL ,
131
+ [ { val : dateInVal , type : oracledb . DB_TYPE_TIMESTAMP } ] ) ;
132
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=180 Len=11' ) ;
133
+ } catch ( err ) {
134
+ should . not . exist ( err ) ;
135
+ }
136
+ } ) ;
137
+
138
+ it ( '226.8 DB_TYPE_TIMESTAMP_TZ' , async ( ) => {
139
+ try {
140
+ const result = await conn . execute ( SQL ,
141
+ [ { val : dateInVal , type : oracledb . DB_TYPE_TIMESTAMP_TZ } ] ) ;
142
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=181 Len=13' ) ;
143
+ } catch ( err ) {
144
+ should . not . exist ( err ) ;
145
+ }
146
+ } ) ;
147
+
148
+ it ( '226.9 DB_TYPE_NUMBER' , async ( ) => {
149
+ try {
150
+ const sql = `SELECT DUMP(:1) FROM dual` ;
151
+ const result = await conn . execute ( sql ,
152
+ [ { val : numInVal , type : oracledb . DB_TYPE_NUMBER } ] ) ;
153
+ ( result . rows [ 0 ] [ 0 ] ) . should . startWith ( 'Typ=2 Len=2' ) ;
154
+ } catch ( err ) {
155
+ should . not . exist ( err ) ;
156
+ }
157
+ } ) ;
158
+
159
+ it ( '226.10 DB_TYPE_BINARY_FLOAT' , async ( ) => {
160
+ try {
161
+ const result = await conn . execute ( SQL ,
162
+ [ { val : numInVal , type : oracledb . DB_TYPE_BINARY_FLOAT } ] ) ;
163
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=100 Len=4' ) ;
164
+ } catch ( err ) {
165
+ should . not . exist ( err ) ;
166
+ }
167
+ } ) ;
168
+
169
+ it ( '226.11 DB_TYPE_BINARY_DOUBLE' , async ( ) => {
170
+ try {
171
+ const result = await conn . execute ( SQL ,
172
+ [ { val : numInVal , type : oracledb . DB_TYPE_BINARY_DOUBLE } ] ) ;
173
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=101 Len=8' ) ;
174
+ } catch ( err ) {
175
+ should . not . exist ( err ) ;
176
+ }
177
+ } ) ;
178
+
179
+ it ( '226.12 Infinity, DB_TYPE_BINARY_FLOAT' , async ( ) => {
180
+ try {
181
+ const num = 1 / 0 ;
182
+ const result = await conn . execute ( SQL ,
183
+ [ { val : num , type : oracledb . DB_TYPE_BINARY_FLOAT } ] ) ;
184
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=100 Len=4' ) ;
185
+ } catch ( err ) {
186
+ should . not . exist ( err ) ;
187
+ }
188
+ } ) ;
189
+
190
+ it ( '226.13 Infinity, DB_TYPE_BINARY_DOUBLE' , async ( ) => {
191
+ try {
192
+ const num = 1 / 0 ;
193
+ const result = await conn . execute ( SQL ,
194
+ [ { val : num , type : oracledb . DB_TYPE_BINARY_DOUBLE } ] ) ;
195
+ ( result . rows [ 0 ] [ 1 ] ) . should . startWith ( 'Typ=101 Len=8' ) ;
196
+ } catch ( err ) {
197
+ should . not . exist ( err ) ;
198
+ }
199
+ } ) ;
200
+ } ) ;
0 commit comments