1919 * 226. dbType01.js
2020 *
2121 * 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_*.
2423 *
2524 *****************************************************************************/
2625'use strict' ;
2726
2827const oracledb = require ( 'oracledb' ) ;
2928const should = require ( 'should' ) ;
3029const dbconfig = require ( './dbconfig.js' ) ;
30+ const testsUtil = require ( './testsUtil.js' ) ;
3131
3232describe ( '226. dbType01.js' , function ( ) {
3333
3434 let conn ;
35+ const default_stmtCacheSize = oracledb . stmtCacheSize ;
3536
3637 before ( async ( ) => {
38+ oracledb . stmtCacheSize = 0 ;
3739 try {
3840 conn = await oracledb . getConnection ( dbconfig ) ;
3941 } catch ( err ) {
@@ -47,17 +49,24 @@ describe('226. dbType01.js', function() {
4749 } catch ( err ) {
4850 should . not . exist ( err ) ;
4951 }
52+ oracledb . stmtCacheSize = default_stmtCacheSize ;
53+ } ) ;
54+
55+ afterEach ( async ( ) => {
56+ await testsUtil . sleep ( 100 ) ;
5057 } ) ;
5158
5259 const strInVal = "Node-oracledb" ;
5360 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` ;
5563
5664 it ( '226.1 DB_TYPE_VARCHAR' , async ( ) => {
5765 try {
5866 const result = await conn . execute ( SQL ,
5967 [ { 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' ) ;
6170 } catch ( err ) {
6271 should . not . exist ( err ) ;
6372 }
@@ -67,7 +76,8 @@ describe('226. dbType01.js', function() {
6776 try {
6877 const result = await conn . execute ( SQL ,
6978 [ { 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' ) ;
7181 } catch ( err ) {
7282 should . not . exist ( err ) ;
7383 }
@@ -77,7 +87,8 @@ describe('226. dbType01.js', function() {
7787 try {
7888 const result = await conn . execute ( SQL ,
7989 [ { 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' ) ;
8192 } catch ( err ) {
8293 should . not . exist ( err ) ;
8394 }
@@ -87,7 +98,8 @@ describe('226. dbType01.js', function() {
8798 try {
8899 const result = await conn . execute ( SQL ,
89100 [ { 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' ) ;
91103 } catch ( err ) {
92104 should . not . exist ( err ) ;
93105 }
@@ -97,7 +109,7 @@ describe('226. dbType01.js', function() {
97109 try {
98110 const result = await conn . execute ( SQL ,
99111 [ { 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' ) ;
101113 } catch ( err ) {
102114 should . not . exist ( err ) ;
103115 }
@@ -107,10 +119,82 @@ describe('226. dbType01.js', function() {
107119 try {
108120 const result = await conn . execute ( SQL ,
109121 [ { 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' ) ;
111123 } catch ( err ) {
112124 should . not . exist ( err ) ;
113125 }
114126 } ) ; // 226.6
115127
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