@@ -788,6 +788,15 @@ describe('294. dataTypeVector1.js', function() {
788
788
oracledb . fetchTypeHandler = function ( ) {
789
789
return { type : oracledb . STRING } ;
790
790
} ;
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
+
791
800
// Create a Float64Array
792
801
const float64Array = new Float64Array (
793
802
[ - 999999.12345 , 987654.321 , - 12345.6789 , 56789.0123 ,
@@ -796,19 +805,28 @@ describe('294. dataTypeVector1.js', function() {
796
805
const expected_vectors = `[-9.9999912344999996E+005,9.87654321E+005,` +
797
806
`-1.2345678900000001E+004,5.6789012300000002E+004,-3.1415926539999997E+005,` +
798
807
`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)` ,
800
809
{ id : 2 ,
801
810
vec64 : float64Array
802
811
} ) ;
803
812
804
813
/* Setting keepInStmtCache as false as
805
814
* we earlier fetched vector as a clob; the same statement is used for fetching it as a string now.
806
815
*/
807
- const result = await connection . execute ( `select Vector64Col from ${ tableName } ` , [ ] , { keepInStmtCache : false } ) ;
816
+ const result = await connection . execute ( `select Vector64Col from ${ table } ` , [ ] , { keepInStmtCache : false } ) ;
808
817
assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expected_vectors ) ;
818
+ await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
809
819
} ) ; // 294.33
810
820
811
821
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
+
812
830
oracledb . fetchTypeHandler = function ( ) {
813
831
return { type : oracledb . STRING } ;
814
832
} ;
@@ -820,7 +838,7 @@ describe('294. dataTypeVector1.js', function() {
820
838
'5.6789012300000002E+004,-3.1415926539999997E+005,2.9182818280000001E+005,' +
821
839
'-9.9999999899999995E+004,4.32109876E+004,-8.7654320999999996E+004,6.5432109799999998E+004]' ;
822
840
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)` ,
824
842
{ id : 2 ,
825
843
vec64 : float64Array
826
844
} ) ;
@@ -831,8 +849,9 @@ describe('294. dataTypeVector1.js', function() {
831
849
832
850
// using fetchInfo
833
851
result = await connection . execute (
834
- `select Vector64Col from ${ tableName } ` , [ ] , options ) ;
852
+ `select Vector64Col from ${ table } ` , [ ] , options ) ;
835
853
assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expected_vectors ) ;
854
+ await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
836
855
} ) ; // 294.34
837
856
838
857
it ( '294.35 add drop rename vector column' , async function ( ) {
@@ -936,7 +955,7 @@ describe('294. dataTypeVector1.js', function() {
936
955
` ;
937
956
938
957
const createTableSql = `
939
- CREATE TABLE ${ vector_case } (
958
+ CREATE TABLE IF NOT EXISTS ${ vector_case } (
940
959
id NUMBER,
941
960
message vector(10)
942
961
)
@@ -1078,28 +1097,28 @@ describe('294. dataTypeVector1.js', function() {
1078
1097
] ;
1079
1098
1080
1099
const expected_vectors = [
1081
- [ 3 , 69.94999999999999 ,
1100
+ [ 3 , 0.10298221668758012 ,
1082
1101
[
1083
1102
1 , 3.2 , 5.4 , 7.6 ,
1084
1103
9.8 , 2.1 , 4.3 , 6.5 ,
1085
1104
8.7 , 0.9
1086
1105
]
1087
1106
] ,
1088
- [ 2 , 143.65 ,
1107
+ [ 2 , 0.21154470130089698 ,
1089
1108
[
1090
1109
0.1 , 1.2 , 2.3 , 3.4 ,
1091
1110
4.5 , 5.6 , 6.7 , 7.8 ,
1092
1111
8.9 , 9
1093
1112
]
1094
1113
] ,
1095
- [ 1 , 187.45 ,
1114
+ [ 1 , 0.27913305239989905 ,
1096
1115
[
1097
1116
8.1 , 7.2 , 6.3 , 5.4 ,
1098
1117
4.5 , 3.6 , 2.7 , 1.8 ,
1099
1118
9.9 , 0
1100
1119
]
1101
1120
] ,
1102
- [ 4 , 197.07 ,
1121
+ [ 4 , 0.28645724726349675 ,
1103
1122
[
1104
1123
2.2 , 8.8 , 4.4 , 6.6 ,
1105
1124
0.2 , 1.1 , 3.3 , 5.5 ,
@@ -1132,6 +1151,16 @@ describe('294. dataTypeVector1.js', function() {
1132
1151
} ) ; // 294.45
1133
1152
1134
1153
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 ) ;
1135
1164
const testValues = [
1136
1165
{ name : 'VectorFixedCol' , dimensions : 2 , format : undefined } ,
1137
1166
{ name : 'VectorInt8Col' , dimensions : 4 , format : oracledb . VECTOR_FORMAT_INT8 } ,
@@ -1142,7 +1171,7 @@ describe('294. dataTypeVector1.js', function() {
1142
1171
for ( const { name, dimensions, format } of testValues ) {
1143
1172
// inserting data into the table
1144
1173
await connection . execute (
1145
- `insert into ${ tableName } (IntCol, ${ name } ) values (1, :1)` ,
1174
+ `insert into ${ table } (IntCol, ${ name } ) values (1, :1)` ,
1146
1175
{
1147
1176
1 : {
1148
1177
val : Array . from ( { length : dimensions } , ( _ , i ) => 0.125 * i ) ,
@@ -1153,20 +1182,19 @@ describe('294. dataTypeVector1.js', function() {
1153
1182
) ;
1154
1183
1155
1184
// 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 } ` , [ ] ) ;
1160
1186
assert . strictEqual ( result . metaData [ 0 ] . vectorDimensions , dimensions ) ;
1161
1187
assert . strictEqual ( result . metaData [ 0 ] . dbType , oracledb . DB_TYPE_VECTOR ) ;
1162
1188
assert . strictEqual ( result . metaData [ 0 ] . vectorFormat , format ) ;
1163
1189
assert . strictEqual ( result . metaData [ 0 ] . isJson , false ) ;
1164
1190
}
1191
+ await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1165
1192
} ) ; // 294.46
1166
1193
1167
1194
it ( '294.47 handling of NULL vector value' , async function ( ) {
1168
1195
const table = 'nodb_vectorDbTable1' ;
1169
- const sql = `CREATE TABLE ${ table } (
1196
+ const sql = `CREATE TABLE IF NOT EXISTS
1197
+ ${ table } (
1170
1198
IntCol NUMBER,
1171
1199
VectorFlex32Col vector(*, float32)
1172
1200
)` ;
@@ -1186,7 +1214,7 @@ describe('294. dataTypeVector1.js', function() {
1186
1214
const arr = Array ( 8127 ) . fill ( 2.5 ) ;
1187
1215
const table = 'nodb_vectorDbTable1' ;
1188
1216
await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1189
- const sql = `CREATE TABLE ${ table } (
1217
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1190
1218
IntCol NUMBER,
1191
1219
VectorFlex32Col vector(*, float32)
1192
1220
)` ;
@@ -1212,7 +1240,7 @@ describe('294. dataTypeVector1.js', function() {
1212
1240
const arr = Array ( 65535 ) . fill ( 2.5 ) ;
1213
1241
const table = 'nodb_vectorDbTable1' ;
1214
1242
await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1215
- const sql = `CREATE TABLE ${ table } (
1243
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1216
1244
IntCol NUMBER,
1217
1245
Vector32Col VECTOR(65535, FLOAT32)
1218
1246
)` ;
@@ -1238,7 +1266,7 @@ describe('294. dataTypeVector1.js', function() {
1238
1266
const arr = Array ( 65535 ) . fill ( 2.5 ) ;
1239
1267
const table = 'nodb_vectorDbTable1' ;
1240
1268
await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1241
- const sql = `CREATE TABLE ${ table } (
1269
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1242
1270
IntCol NUMBER,
1243
1271
VectorFlex64Col vector(*, float64)
1244
1272
)` ;
@@ -1264,7 +1292,7 @@ describe('294. dataTypeVector1.js', function() {
1264
1292
const arr = Array ( 65533 ) . fill ( 2.5 ) ;
1265
1293
const table = 'nodb_vectorDbTable1' ;
1266
1294
await connection . execute ( testsUtil . sqlDropTable ( table ) ) ;
1267
- const sql = `CREATE TABLE ${ table } (
1295
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1268
1296
IntCol NUMBER,
1269
1297
Vector32Col VECTOR(65533, FLOAT32)
1270
1298
)` ;
@@ -1288,7 +1316,7 @@ describe('294. dataTypeVector1.js', function() {
1288
1316
it ( '294.52 insert a float64 vector with 65535 dimensions to flex float32 vector' , async function ( ) {
1289
1317
const arr = Array ( 65535 ) . fill ( 0.002253931947052479 ) ;
1290
1318
const table = 'nodb_vectorDbTable1' ;
1291
- const sql = `CREATE TABLE ${ table } (
1319
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1292
1320
IntCol NUMBER,
1293
1321
Vector32Col VECTOR(65535, FLOAT32)
1294
1322
)` ;
@@ -1314,7 +1342,7 @@ describe('294. dataTypeVector1.js', function() {
1314
1342
const int8arr = new Int8Array ( arr ) ;
1315
1343
1316
1344
const table = 'nodb_vectorDbTable1' ;
1317
- const sql = `CREATE TABLE ${ table } (
1345
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1318
1346
IntCol NUMBER,
1319
1347
VectorFlex8Col VECTOR(*, INT8)
1320
1348
)` ;
@@ -1338,7 +1366,7 @@ describe('294. dataTypeVector1.js', function() {
1338
1366
1339
1367
it ( '294.54 insert using executeMany, update, delete and select vectors' , async function ( ) {
1340
1368
const table = 'nodb_vectorDbTable1' ;
1341
- const sql = `CREATE TABLE ${ table } (
1369
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1342
1370
IntCol NUMBER,
1343
1371
Vector64Col VECTOR(3, FLOAT64)
1344
1372
)` ;
@@ -1398,7 +1426,7 @@ describe('294. dataTypeVector1.js', function() {
1398
1426
// Write the buffer to the CLOB
1399
1427
await lob . write ( JSON . stringify ( arr ) ) ;
1400
1428
const table = 'nodb_vectorDbTable1' ;
1401
- let sql = `CREATE TABLE ${ table } (
1429
+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1402
1430
IntCol NUMBER,
1403
1431
VectorCol VECTOR
1404
1432
)` ;
@@ -1429,7 +1457,7 @@ describe('294. dataTypeVector1.js', function() {
1429
1457
1430
1458
it ( '294.56 insert vector as clob to Int8 column' , async function ( ) {
1431
1459
const table = 'nodb_vectorDbTable1' ;
1432
- let sql = `CREATE TABLE ${ table } (
1460
+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1433
1461
IntCol NUMBER,
1434
1462
VectorInt8Col vector(3, int8)
1435
1463
)` ;
@@ -1465,7 +1493,7 @@ describe('294. dataTypeVector1.js', function() {
1465
1493
1466
1494
it ( '294.57 insert vector as clob to float64 column' , async function ( ) {
1467
1495
const table = 'nodb_vectorDbTable1' ;
1468
- let sql = `CREATE TABLE ${ table } (
1496
+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1469
1497
IntCol NUMBER,
1470
1498
Vector64Col VECTOR(3, FLOAT64)
1471
1499
)` ;
@@ -1502,7 +1530,7 @@ describe('294. dataTypeVector1.js', function() {
1502
1530
1503
1531
it ( '294.58 insert vector as clob to float32 column' , async function ( ) {
1504
1532
const table = 'nodb_vectorDbTable1' ;
1505
- let sql = `CREATE TABLE ${ table } (
1533
+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1506
1534
IntCol NUMBER,
1507
1535
Vector32Col VECTOR(3, FLOAT32)
1508
1536
)` ;
@@ -1541,7 +1569,7 @@ describe('294. dataTypeVector1.js', function() {
1541
1569
const arr = Array ( maxval ) . fill ( 12 ) ;
1542
1570
1543
1571
const table = 'nodb_vectorDbTable1' ;
1544
- const sql = `CREATE TABLE ${ table } (
1572
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1545
1573
IntCol NUMBER,
1546
1574
Vector64Col VECTOR(${ maxval } , FLOAT64)
1547
1575
)` ;
@@ -1585,7 +1613,7 @@ describe('294. dataTypeVector1.js', function() {
1585
1613
// Write the buffer to the CLOB
1586
1614
await lob . write ( JSON . stringify ( arr1 ) ) ;
1587
1615
const table = 'nodb_vectorDbTable1' ;
1588
- let sql = `CREATE TABLE ${ table } (
1616
+ let sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1589
1617
IntCol NUMBER,
1590
1618
VectorCol VECTOR
1591
1619
)` ;
@@ -1632,7 +1660,7 @@ describe('294. dataTypeVector1.js', function() {
1632
1660
const arr = Array ( 65535 ) . fill ( 0.002253931947052479 ) ;
1633
1661
1634
1662
const table = 'nodb_vectorDbTable66' ;
1635
- const sql = `CREATE TABLE ${ table } (
1663
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1636
1664
IntCol NUMBER,
1637
1665
Vector32Col VECTOR(65535, FLOAT32)
1638
1666
)` ;
@@ -1704,7 +1732,7 @@ describe('294. dataTypeVector1.js', function() {
1704
1732
1705
1733
it ( '294.65 bind JSON value with an embedded vector' , async function ( ) {
1706
1734
const table = 'nodb_vector_desc_65' ;
1707
- const sql = `CREATE TABLE ${ table } (
1735
+ const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1708
1736
IntCol number(9) not null,
1709
1737
JsonCol json not null
1710
1738
)` ;
@@ -1840,7 +1868,7 @@ describe('294. dataTypeVector1.js', function() {
1840
1868
assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , [ 1 , 0 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ] ) ;
1841
1869
} ) ; // 294.71
1842
1870
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 ( ) {
1844
1872
const emptyVector = [ ] ;
1845
1873
const columns = [ 'VectorFixedCol' , 'VectorFlexCol' , 'VectorFlex32Col' ,
1846
1874
'VectorFlex64Col' ,
@@ -1860,12 +1888,14 @@ describe('294. dataTypeVector1.js', function() {
1860
1888
sql ,
1861
1889
binds
1862
1890
) ,
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 : /
1864
1892
/*
1865
1893
ORA-51803: Vector dimension count must match the dimension count
1866
1894
specified in the column definition (actual: , required: ).
1895
+ ORA-21560: argument at position 4 (vdim) is null, invalid, or out of range'
1867
1896
*/
1868
1897
) ;
1869
1898
}
1870
1899
} ) ; // 294.72
1871
1900
} ) ;
1901
+
0 commit comments