@@ -788,6 +788,15 @@ describe('294. dataTypeVector1.js', function() {
788788 oracledb . fetchTypeHandler = function ( ) {
789789 return { type : oracledb . STRING } ;
790790 } ;
791+
792+ const table = 'nodb_vectorDbTable1' ;
793+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
794+ IntCol NUMBER,
795+ Vector64Col vector(10, float64)
796+ )` ;
797+ const plsql = testsUtil . sqlCreateTable ( table , sql ) ;
798+ await connection . execute ( plsql ) ;
799+
791800 // Create a Float64Array
792801 const float64Array = new Float64Array (
793802 [ - 999999.12345 , 987654.321 , - 12345.6789 , 56789.0123 ,
@@ -796,19 +805,28 @@ describe('294. dataTypeVector1.js', function() {
796805 const expected_vectors = `[-9.9999912344999996E+005,9.87654321E+005,` +
797806 `-1.2345678900000001E+004,5.6789012300000002E+004,-3.1415926539999997E+005,` +
798807 `2.9182818280000001E+005,-9.9999999899999995E+004,4.32109876E+004,-8.7654320999999996E+004,6.5432109799999998E+004]` ;
799- await connection . execute ( `insert into ${ tableName } (IntCol, Vector64Col) values(:id, :vec64)` ,
808+ await connection . execute ( `insert into ${ table } (IntCol, Vector64Col) values(:id, :vec64)` ,
800809 { id : 2 ,
801810 vec64 : float64Array
802811 } ) ;
803812
804813 /* Setting keepInStmtCache as false as
805814 * we earlier fetched vector as a clob; the same statement is used for fetching it as a string now.
806815 */
807- const result = await connection . execute ( `select Vector64Col from ${ tableName } ` , [ ] , { keepInStmtCache : false } ) ;
816+ const result = await connection . execute ( `select Vector64Col from ${ table } ` , [ ] , { keepInStmtCache : false } ) ;
808817 assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expected_vectors ) ;
818+ await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
809819 } ) ; // 294.33
810820
811821 it ( '294.34 Fetch Vector Column as string using fetchInfo' , async function ( ) {
822+ const table = 'nodb_vectorDbTable1' ;
823+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
824+ IntCol NUMBER,
825+ Vector64Col vector(10, float64)
826+ )` ;
827+ const plsql = testsUtil . sqlCreateTable ( table , sql ) ;
828+ await connection . execute ( plsql ) ;
829+
812830 oracledb . fetchTypeHandler = function ( ) {
813831 return { type : oracledb . STRING } ;
814832 } ;
@@ -820,7 +838,7 @@ describe('294. dataTypeVector1.js', function() {
820838 '5.6789012300000002E+004,-3.1415926539999997E+005,2.9182818280000001E+005,' +
821839 '-9.9999999899999995E+004,4.32109876E+004,-8.7654320999999996E+004,6.5432109799999998E+004]' ;
822840
823- let result = await connection . execute ( `insert into ${ tableName } (IntCol, Vector64Col) values(:id, :vec64)` ,
841+ let result = await connection . execute ( `insert into ${ table } (IntCol, Vector64Col) values(:id, :vec64)` ,
824842 { id : 2 ,
825843 vec64 : float64Array
826844 } ) ;
@@ -831,8 +849,9 @@ describe('294. dataTypeVector1.js', function() {
831849
832850 // using fetchInfo
833851 result = await connection . execute (
834- `select Vector64Col from ${ tableName } ` , [ ] , options ) ;
852+ `select Vector64Col from ${ table } ` , [ ] , options ) ;
835853 assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expected_vectors ) ;
854+ await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
836855 } ) ; // 294.34
837856
838857 it ( '294.35 add drop rename vector column' , async function ( ) {
@@ -936,7 +955,7 @@ describe('294. dataTypeVector1.js', function() {
936955 ` ;
937956
938957 const createTableSql = `
939- CREATE TABLE ${ vector_case } (
958+ CREATE TABLE IF NOT EXISTS ${ vector_case } (
940959 id NUMBER,
941960 message vector(10)
942961 )
@@ -1078,28 +1097,28 @@ describe('294. dataTypeVector1.js', function() {
10781097 ] ;
10791098
10801099 const expected_vectors = [
1081- [ 3 , 69.94999999999999 ,
1100+ [ 3 , 0.10298221668758012 ,
10821101 [
10831102 1 , 3.2 , 5.4 , 7.6 ,
10841103 9.8 , 2.1 , 4.3 , 6.5 ,
10851104 8.7 , 0.9
10861105 ]
10871106 ] ,
1088- [ 2 , 143.65 ,
1107+ [ 2 , 0.21154470130089698 ,
10891108 [
10901109 0.1 , 1.2 , 2.3 , 3.4 ,
10911110 4.5 , 5.6 , 6.7 , 7.8 ,
10921111 8.9 , 9
10931112 ]
10941113 ] ,
1095- [ 1 , 187.45 ,
1114+ [ 1 , 0.27913305239989905 ,
10961115 [
10971116 8.1 , 7.2 , 6.3 , 5.4 ,
10981117 4.5 , 3.6 , 2.7 , 1.8 ,
10991118 9.9 , 0
11001119 ]
11011120 ] ,
1102- [ 4 , 197.07 ,
1121+ [ 4 , 0.28645724726349675 ,
11031122 [
11041123 2.2 , 8.8 , 4.4 , 6.6 ,
11051124 0.2 , 1.1 , 3.3 , 5.5 ,
@@ -1132,6 +1151,16 @@ describe('294. dataTypeVector1.js', function() {
11321151 } ) ; // 294.45
11331152
11341153 it ( '294.46 fetching vector Metadata' , async function ( ) {
1154+ const table = 'nodb_vectorDbTable2' ;
1155+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1156+ IntCol NUMBER,
1157+ VectorFixedCol vector(2),
1158+ Vector32Col vector(10, float32),
1159+ Vector64Col vector(10, float64),
1160+ VectorInt8Col vector(4, int8)
1161+ )` ;
1162+ const plsql = testsUtil . sqlCreateTable ( table , sql ) ;
1163+ await connection . execute ( plsql ) ;
11351164 const testValues = [
11361165 { name : 'VectorFixedCol' , dimensions : 2 , format : undefined } ,
11371166 { name : 'VectorInt8Col' , dimensions : 4 , format : oracledb . VECTOR_FORMAT_INT8 } ,
@@ -1142,7 +1171,7 @@ describe('294. dataTypeVector1.js', function() {
11421171 for ( const { name, dimensions, format } of testValues ) {
11431172 // inserting data into the table
11441173 await connection . execute (
1145- `insert into ${ tableName } (IntCol, ${ name } ) values (1, :1)` ,
1174+ `insert into ${ table } (IntCol, ${ name } ) values (1, :1)` ,
11461175 {
11471176 1 : {
11481177 val : Array . from ( { length : dimensions } , ( _ , i ) => 0.125 * i ) ,
@@ -1153,20 +1182,19 @@ describe('294. dataTypeVector1.js', function() {
11531182 ) ;
11541183
11551184 // Fetching data from the table
1156- /* Setting keepInStmtCache as false as
1157- * we earlier fetched vector as a clob; the same statement is used for fetching it as a string now.
1158- */
1159- const result = await connection . execute ( `select ${ name } from ${ tableName } ` , [ ] , { keepInStmtCache : false } ) ;
1185+ const result = await connection . execute ( `select ${ name } from ${ table } ` , [ ] ) ;
11601186 assert . strictEqual ( result . metaData [ 0 ] . vectorDimensions , dimensions ) ;
11611187 assert . strictEqual ( result . metaData [ 0 ] . dbType , oracledb . DB_TYPE_VECTOR ) ;
11621188 assert . strictEqual ( result . metaData [ 0 ] . vectorFormat , format ) ;
11631189 assert . strictEqual ( result . metaData [ 0 ] . isJson , false ) ;
11641190 }
1191+ await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
11651192 } ) ; // 294.46
11661193
11671194 it ( '294.47 handling of NULL vector value' , async function ( ) {
11681195 const table = 'nodb_vectorDbTable1' ;
1169- const sql = `CREATE TABLE ${ table } (
1196+ const sql = `CREATE TABLE IF NOT EXISTS
1197+ ${ table } (
11701198 IntCol NUMBER,
11711199 VectorFlex32Col vector(*, float32)
11721200 )` ;
@@ -1186,7 +1214,7 @@ describe('294. dataTypeVector1.js', function() {
11861214 const arr = Array ( 8127 ) . fill ( 2.5 ) ;
11871215 const table = 'nodb_vectorDbTable1' ;
11881216 await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1189- const sql = `CREATE TABLE ${ table } (
1217+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
11901218 IntCol NUMBER,
11911219 VectorFlex32Col vector(*, float32)
11921220 )` ;
@@ -1212,7 +1240,7 @@ describe('294. dataTypeVector1.js', function() {
12121240 const arr = Array ( 65535 ) . fill ( 2.5 ) ;
12131241 const table = 'nodb_vectorDbTable1' ;
12141242 await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1215- const sql = `CREATE TABLE ${ table } (
1243+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
12161244 IntCol NUMBER,
12171245 Vector32Col VECTOR(65535, FLOAT32)
12181246 )` ;
@@ -1238,7 +1266,7 @@ describe('294. dataTypeVector1.js', function() {
12381266 const arr = Array ( 65535 ) . fill ( 2.5 ) ;
12391267 const table = 'nodb_vectorDbTable1' ;
12401268 await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1241- const sql = `CREATE TABLE ${ table } (
1269+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
12421270 IntCol NUMBER,
12431271 VectorFlex64Col vector(*, float64)
12441272 )` ;
@@ -1264,7 +1292,7 @@ describe('294. dataTypeVector1.js', function() {
12641292 const arr = Array ( 65533 ) . fill ( 2.5 ) ;
12651293 const table = 'nodb_vectorDbTable1' ;
12661294 await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1267- const sql = `CREATE TABLE ${ table } (
1295+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
12681296 IntCol NUMBER,
12691297 Vector32Col VECTOR(65533, FLOAT32)
12701298 )` ;
@@ -1288,7 +1316,7 @@ describe('294. dataTypeVector1.js', function() {
12881316 it ( '294.52 insert a float64 vector with 65535 dimensions to flex float32 vector' , async function ( ) {
12891317 const arr = Array ( 65535 ) . fill ( 0.002253931947052479 ) ;
12901318 const table = 'nodb_vectorDbTable1' ;
1291- const sql = `CREATE TABLE ${ table } (
1319+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
12921320 IntCol NUMBER,
12931321 Vector32Col VECTOR(65535, FLOAT32)
12941322 )` ;
@@ -1314,7 +1342,7 @@ describe('294. dataTypeVector1.js', function() {
13141342 const int8arr = new Int8Array ( arr ) ;
13151343
13161344 const table = 'nodb_vectorDbTable1' ;
1317- const sql = `CREATE TABLE ${ table } (
1345+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
13181346 IntCol NUMBER,
13191347 VectorFlex8Col VECTOR(*, INT8)
13201348 )` ;
@@ -1338,7 +1366,7 @@ describe('294. dataTypeVector1.js', function() {
13381366
13391367 it ( '294.54 insert using executeMany, update, delete and select vectors' , async function ( ) {
13401368 const table = 'nodb_vectorDbTable1' ;
1341- const sql = `CREATE TABLE ${ table } (
1369+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
13421370 IntCol NUMBER,
13431371 Vector64Col VECTOR(3, FLOAT64)
13441372 )` ;
@@ -1398,7 +1426,7 @@ describe('294. dataTypeVector1.js', function() {
13981426 // Write the buffer to the CLOB
13991427 await lob . write ( JSON . stringify ( arr ) ) ;
14001428 const table = 'nodb_vectorDbTable1' ;
1401- let sql = `CREATE TABLE ${ table } (
1429+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
14021430 IntCol NUMBER,
14031431 VectorCol VECTOR
14041432 )` ;
@@ -1429,7 +1457,7 @@ describe('294. dataTypeVector1.js', function() {
14291457
14301458 it ( '294.56 insert vector as clob to Int8 column' , async function ( ) {
14311459 const table = 'nodb_vectorDbTable1' ;
1432- let sql = `CREATE TABLE ${ table } (
1460+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
14331461 IntCol NUMBER,
14341462 VectorInt8Col vector(3, int8)
14351463 )` ;
@@ -1465,7 +1493,7 @@ describe('294. dataTypeVector1.js', function() {
14651493
14661494 it ( '294.57 insert vector as clob to float64 column' , async function ( ) {
14671495 const table = 'nodb_vectorDbTable1' ;
1468- let sql = `CREATE TABLE ${ table } (
1496+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
14691497 IntCol NUMBER,
14701498 Vector64Col VECTOR(3, FLOAT64)
14711499 )` ;
@@ -1502,7 +1530,7 @@ describe('294. dataTypeVector1.js', function() {
15021530
15031531 it ( '294.58 insert vector as clob to float32 column' , async function ( ) {
15041532 const table = 'nodb_vectorDbTable1' ;
1505- let sql = `CREATE TABLE ${ table } (
1533+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
15061534 IntCol NUMBER,
15071535 Vector32Col VECTOR(3, FLOAT32)
15081536 )` ;
@@ -1541,7 +1569,7 @@ describe('294. dataTypeVector1.js', function() {
15411569 const arr = Array ( maxval ) . fill ( 12 ) ;
15421570
15431571 const table = 'nodb_vectorDbTable1' ;
1544- const sql = `CREATE TABLE ${ table } (
1572+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
15451573 IntCol NUMBER,
15461574 Vector64Col VECTOR(${ maxval } , FLOAT64)
15471575 )` ;
@@ -1585,7 +1613,7 @@ describe('294. dataTypeVector1.js', function() {
15851613 // Write the buffer to the CLOB
15861614 await lob . write ( JSON . stringify ( arr1 ) ) ;
15871615 const table = 'nodb_vectorDbTable1' ;
1588- let sql = `CREATE TABLE ${ table } (
1616+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
15891617 IntCol NUMBER,
15901618 VectorCol VECTOR
15911619 )` ;
@@ -1632,7 +1660,7 @@ describe('294. dataTypeVector1.js', function() {
16321660 const arr = Array ( 65535 ) . fill ( 0.002253931947052479 ) ;
16331661
16341662 const table = 'nodb_vectorDbTable66' ;
1635- const sql = `CREATE TABLE ${ table } (
1663+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
16361664 IntCol NUMBER,
16371665 Vector32Col VECTOR(65535, FLOAT32)
16381666 )` ;
@@ -1704,7 +1732,7 @@ describe('294. dataTypeVector1.js', function() {
17041732
17051733 it ( '294.65 bind JSON value with an embedded vector' , async function ( ) {
17061734 const table = 'nodb_vector_desc_65' ;
1707- const sql = `CREATE TABLE ${ table } (
1735+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
17081736 IntCol number(9) not null,
17091737 JsonCol json not null
17101738 )` ;
@@ -1840,7 +1868,7 @@ describe('294. dataTypeVector1.js', function() {
18401868 assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , [ 1 , 0 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ] ) ;
18411869 } ) ; // 294.71
18421870
1843- it ( '294.72 inserting empty vector in Fixed and Flex vector columns' , async function ( ) {
1871+ it . skip ( '294.72 inserting empty vector in Fixed and Flex vector columns' , async function ( ) {
18441872 const emptyVector = [ ] ;
18451873 const columns = [ 'VectorFixedCol' , 'VectorFlexCol' , 'VectorFlex32Col' ,
18461874 'VectorFlex64Col' ,
@@ -1860,12 +1888,14 @@ describe('294. dataTypeVector1.js', function() {
18601888 sql ,
18611889 binds
18621890 ) ,
1863- / O R A - 5 1 8 0 3 : /
1891+ / O R A - 5 1 8 0 3 : | O R A - 2 1 5 6 0 : /
18641892 /*
18651893 ORA-51803: Vector dimension count must match the dimension count
18661894 specified in the column definition (actual: , required: ).
1895+ ORA-21560: argument at position 4 (vdim) is null, invalid, or out of range'
18671896 */
18681897 ) ;
18691898 }
18701899 } ) ; // 294.72
18711900} ) ;
1901+
0 commit comments