@@ -39,10 +39,14 @@ const assist = require('./dataTypeAssist.js');
3939
4040describe ( '294. dataTypeVector1.js' , function ( ) {
4141 let connection = null , isRunnable = false , defaultFetchTypeHandler ;
42+ let isVectorBinaryRunnable = false ;
4243
4344 before ( 'Get connection' , async function ( ) {
4445 isRunnable = await testsUtil . checkPrerequisites ( 2304000000 , 2304000000 ) ;
4546 if ( ! isRunnable ) this . skip ( ) ;
47+ if ( await testsUtil . isVectorBinaryRunnable ( ) ) {
48+ isVectorBinaryRunnable = true ;
49+ }
4650
4751 defaultFetchTypeHandler = oracledb . fetchTypeHandler ;
4852 connection = await oracledb . getConnection ( dbConfig ) ;
@@ -58,25 +62,43 @@ describe('294. dataTypeVector1.js', function() {
5862 const tableName = 'nodb_vectorDbTable' ;
5963
6064 before ( 'Create table' , async function ( ) {
61- const sql = `CREATE TABLE ${ tableName } (
62- IntCol NUMBER(9) NOT NULL,
63- VectorCol VECTOR,
64- VectorFixedCol VECTOR(2),
65- Vector32Col VECTOR(10, float32),
66- Vector64Col VECTOR(10, float64),
67- VectorInt8Col VECTOR(4, int8),
68- VectorBinaryCol VECTOR(16, binary),
69- VectorFlexCol VECTOR(*, *),
70- VectorFlex32Col VECTOR(*, float32),
71- VectorFlex64Col VECTOR(*, float64),
72- VectorFlex8Col VECTOR(*, int8),
73- VectorFlexBinaryCol VECTOR(*, binary)
74- )` ;
65+ let sql ;
66+ if ( isVectorBinaryRunnable ) {
67+ sql = `CREATE TABLE ${ tableName } (
68+ IntCol NUMBER(9) NOT NULL,
69+ VectorCol VECTOR,
70+ VectorFixedCol VECTOR(2),
71+ Vector32Col VECTOR(10, float32),
72+ Vector64Col VECTOR(10, float64),
73+ VectorInt8Col VECTOR(4, int8),
74+ VectorBinaryCol VECTOR(16, binary),
75+ VectorFlexCol VECTOR(*, *),
76+ VectorFlex32Col VECTOR(*, float32),
77+ VectorFlex64Col VECTOR(*, float64),
78+ VectorFlex8Col VECTOR(*, int8),
79+ VectorFlexBinaryCol VECTOR(*, binary)
80+ )` ;
81+ } else {
82+ sql = `CREATE TABLE ${ tableName } (
83+ IntCol NUMBER(9) NOT NULL,
84+ VectorCol VECTOR,
85+ VectorFixedCol VECTOR(2),
86+ Vector32Col VECTOR(10, float32),
87+ Vector64Col VECTOR(10, float64),
88+ VectorInt8Col VECTOR(4, int8),
89+ VectorFlexCol VECTOR(*, *),
90+ VectorFlex32Col VECTOR(*, float32),
91+ VectorFlex64Col VECTOR(*, float64),
92+ VectorFlex8Col VECTOR(*, int8)
93+ )` ;
94+ }
95+
7596 const plsql = testsUtil . sqlCreateTable ( tableName , sql ) ;
7697 await connection . execute ( plsql ) ;
7798 } ) ;
7899
79100 after ( 'Release connection' , async function ( ) {
101+ isVectorBinaryRunnable = false ;
80102 await connection . execute ( testsUtil . sqlDropTable ( tableName ) ) ;
81103 } ) ;
82104
@@ -185,6 +207,8 @@ describe('294. dataTypeVector1.js', function() {
185207 } ) ; // 294.1.4
186208
187209 it ( '294.1.5 binding a binary vector type with various number typed arrays' , async function ( ) {
210+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
211+
188212 const uInt8Arr1 = new Uint8Array ( [ 3 , 4 ] ) ;
189213 let binds = [
190214 { type : oracledb . DB_TYPE_VECTOR , val : uInt8Arr1 } ,
@@ -210,6 +234,8 @@ describe('294. dataTypeVector1.js', function() {
210234 } ) ; // 294.1.5
211235
212236 it ( '294.1.6 update binary vector type into table' , async function ( ) {
237+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
238+
213239 const uInt8Arr1 = new Uint8Array ( [ 3 , 4 ] ) ;
214240 let binds = [
215241 { type : oracledb . DB_TYPE_VECTOR , val : uInt8Arr1 } ,
@@ -237,23 +263,25 @@ describe('294. dataTypeVector1.js', function() {
237263 `SELECT VECTOR('[34.6, 77.8]', 2, float32) FROM dual` ,
238264 `SELECT VECTOR('[34.6, 77.8, -89.34]', 3, float32) FROM dual` ,
239265 `SELECT TO_VECTOR('[34.6, 77.8]', 2, float32) FROM dual` ,
240- `SELECT TO_VECTOR('[34.6, 77.8, -89.34]', 3, float32) FROM dual` ,
241- `SELECT TO_VECTOR('[1]', 8, binary) FROM dual`
266+ `SELECT TO_VECTOR('[34.6, 77.8, -89.34]', 3, float32) FROM dual`
242267 ] ;
268+ if ( isVectorBinaryRunnable )
269+ statements . push ( `SELECT TO_VECTOR('[1]', 8, binary) FROM dual` ) ;
243270
244271 /* eslint-disable no-loss-of-precision */
245272
246- const expected_vectors = [
273+ const expectedVectors = [
247274 [ 34.599998474121094 , 77.80000305175781 ] ,
248275 [ 34.599998474121094 , 77.80000305175781 , - 89.33999633789062 ] ,
249276 [ 34.599998474121094 , 77.80000305175781 ] ,
250- [ 34.599998474121094 , 77.80000305175781 , - 89.33999633789062 ] ,
251- [ 1 ]
277+ [ 34.599998474121094 , 77.80000305175781 , - 89.33999633789062 ]
252278 ] ;
279+ if ( isVectorBinaryRunnable )
280+ expectedVectors . push ( [ 1 ] ) ;
253281
254282 for ( let i = 0 ; i < statements . length ; i ++ ) {
255283 const result = await connection . execute ( statements [ i ] ) ;
256- assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expected_vectors [ i ] ) ;
284+ assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , expectedVectors [ i ] ) ;
257285 }
258286 } ) ; // 294.1.7
259287
@@ -354,6 +382,8 @@ describe('294. dataTypeVector1.js', function() {
354382 } ) ; // 294.1.12
355383
356384 it ( '294.1.13 insert a float32 vector into an Binary column (negative)' , async function ( ) {
385+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
386+
357387 // Create a Float32Array
358388 const float32Array = new Float32Array ( [ - 5 , 4 , - 7 , 6 , 2 , 3 , 4 , 5 , 6 , 7 , 7 , 10 , 11 , 12 , 13 , 16 ] ) ;
359389
@@ -434,6 +464,8 @@ describe('294. dataTypeVector1.js', function() {
434464 } ) ; // 294.1.16
435465
436466 it ( '294.1.17 insert a float32 typed array into an binary vector column' , async function ( ) {
467+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
468+
437469 // Create a Float32Array
438470 const float32Array = new Float32Array ( [ - 5 , 4 , - 7 , 6 , 2 , 3 , 4 , 5 , 6 , 7 , 7 , 10 , 11 , 12 , 13 , 16 ] ) ;
439471
@@ -526,6 +558,8 @@ describe('294. dataTypeVector1.js', function() {
526558 } ) ; // 294.1.21
527559
528560 it ( '294.1.22 insert a float64 typed array into an Binary vector column' , async function ( ) {
561+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
562+
529563 // Create a Float32Array
530564 const float64Array = new Float64Array ( [ - 5 , 4 , - 7 , 6 , 2 , 3 , 4 , 5 , 6 , 7 , 7 , 10 , 11 , 12 , 13 , 16 ] ) ;
531565
@@ -715,6 +749,7 @@ describe('294. dataTypeVector1.js', function() {
715749 } ) ; // 294.1.30
716750
717751 it ( '294.1.31 inserting vector binary with invalid values' , async function ( ) {
752+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
718753
719754 const sql = `INSERT INTO ${ tableName } (IntCol, VectorBinaryCol)
720755 VALUES(2, :1)` ;
@@ -1187,6 +1222,8 @@ describe('294. dataTypeVector1.js', function() {
11871222 } ) ; // 294.1.48
11881223
11891224 it ( '294.1.49 dml returning vector binary type' , async function ( ) {
1225+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1226+
11901227 const sql = `INSERT INTO ${ tableName } (IntCol, VectorBinaryCol)
11911228 VALUES(1, :value)
11921229 RETURNING VectorBinaryCol INTO :vector_val` ;
@@ -1253,6 +1290,8 @@ describe('294. dataTypeVector1.js', function() {
12531290 } ) ; // 294.1.51
12541291
12551292 it ( '294.1.52 executeMany with positional args in vector binary flex column' , async function ( ) {
1293+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1294+
12561295 const rows = [
12571296 [ 1 , [ 1 , 2 ] ] ,
12581297 [ 2 , [ 3 , 4 ] ] ,
@@ -1277,6 +1316,8 @@ describe('294. dataTypeVector1.js', function() {
12771316 } ) ; // 294.1.52
12781317
12791318 it ( '294.1.53 handling of NULLs and default values for vector binary type' , async function ( ) {
1319+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1320+
12801321 // insert with default value
12811322 await connection . execute ( `
12821323 INSERT INTO ${ tableName } (IntCol) VALUES (1)
@@ -1305,6 +1346,8 @@ describe('294. dataTypeVector1.js', function() {
13051346 } ) ; // 294.1.53
13061347
13071348 it ( '294.1.54 ORDER BY and GROUP BY with vector binary type as negative test' , async function ( ) {
1349+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1350+
13081351 await assert . rejects (
13091352 async ( ) => await connection . execute ( `SELECT VectorFlexBinaryCol, COUNT(*) as count
13101353 FROM ${ tableName }
@@ -1449,6 +1492,8 @@ describe('294. dataTypeVector1.js', function() {
14491492 } ) ; // 294.1.58
14501493
14511494 it ( '294.1.59 typed arrays with strings' , async function ( ) {
1495+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1496+
14521497 // Create a Float32Array with strings
14531498 const float32ArrayWithString = new Float32Array ( [ 1 , 'invalid' , 3 , 4 ] ) ;
14541499
@@ -1489,6 +1534,8 @@ describe('294. dataTypeVector1.js', function() {
14891534 } ) ; // 294.1.60
14901535
14911536 it ( '294.1.61 typed arrays with boolean values' , async function ( ) {
1537+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1538+
14921539 // Create a uint8Arr with boolean values
14931540 const uInt8Arr = new Uint8Array ( [ true , false ] ) ;
14941541 // Bind the uint8Arr using oracledb.DB_TYPE_VECTOR
@@ -1506,6 +1553,8 @@ describe('294. dataTypeVector1.js', function() {
15061553 } ) ; // 294.1.61
15071554
15081555 it ( '294.1.62 typed arrays with undefined value in vector binary type column' , async function ( ) {
1556+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1557+
15091558 // Create a uint8Arr with undefined value
15101559 const uInt8Arr = new Uint8Array ( [ 1 , undefined ] ) ;
15111560
@@ -1524,6 +1573,8 @@ describe('294. dataTypeVector1.js', function() {
15241573 } ) ; // 294.1.62
15251574
15261575 it ( '294.1.63 typed arrays with null values' , async function ( ) {
1576+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
1577+
15271578 // Create a Float32Array with null values
15281579 const uInt8Arr = new Uint8Array ( [ 1 , null ] ) ;
15291580
@@ -1806,25 +1857,39 @@ describe('294. dataTypeVector1.js', function() {
18061857 it ( '294.2.3 fetching vector metadata' , async function ( ) {
18071858 // Using the same table name as the previous test gives an error
18081859 table = 'nodb_vectorDbTable2' ;
1809- const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1860+ let sql ;
1861+ if ( isVectorBinaryRunnable ) {
1862+ sql = `CREATE TABLE IF NOT EXISTS ${ table } (
18101863 IntCol NUMBER,
18111864 VectorFixedCol VECTOR(2),
18121865 Vector32Col VECTOR(10, float32),
18131866 Vector64Col VECTOR(10, float64),
18141867 VectorInt8Col VECTOR(4, int8),
18151868 VectorBinaryCol VECTOR(16, binary)
18161869 )` ;
1870+ } else {
1871+ sql = `CREATE TABLE IF NOT EXISTS ${ table } (
1872+ IntCol NUMBER,
1873+ VectorFixedCol VECTOR(2),
1874+ Vector32Col VECTOR(10, float32),
1875+ Vector64Col VECTOR(10, float64),
1876+ VectorInt8Col VECTOR(4, int8)
1877+ )` ;
1878+ }
1879+
18171880 const plsql = testsUtil . sqlCreateTable ( table , sql ) ;
18181881 await connection . execute ( plsql ) ;
18191882
18201883 const testValues = [
18211884 { name : 'VectorFixedCol' , dimensions : 2 , format : undefined } ,
1822- { name : 'VectorInt8Col' , dimensions : 4 , format : oracledb . VECTOR_FORMAT_INT8 } ,
1823- { name : 'Vector32Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT32 } ,
1824- { name : 'Vector64Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT64 } ,
1825- { name : 'VectorBinaryCol' , dimensions : 16 , format : oracledb . VECTOR_FORMAT_BINARY } ,
1885+ { name : 'VectorInt8Col' , dimensions : 4 , format : oracledb . VECTOR_FORMAT_INT8 } ,
1886+ { name : 'Vector32Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT32 } ,
1887+ { name : 'Vector64Col' , dimensions : 10 , format : oracledb . VECTOR_FORMAT_FLOAT64 } ,
18261888 ] ;
18271889
1890+ if ( isVectorBinaryRunnable )
1891+ testValues . push ( { name : 'VectorBinaryCol' , dimensions : 16 , format : oracledb . VECTOR_FORMAT_BINARY } ) ;
1892+
18281893 for ( const { name, dimensions, format } of testValues ) {
18291894 const vectorData = name === 'VectorBinaryCol' ?
18301895 new Uint8Array ( [ 3 , 4 ] ) : Array . from ( { length : dimensions } , ( _ , i ) => 0.125 * i ) ;
@@ -2016,6 +2081,8 @@ describe('294. dataTypeVector1.js', function() {
20162081 } ) ; // 294.2.10
20172082
20182083 it ( '294.2.11 insert a uint8 vector with 65536 dimensions to flex binary column' , async function ( ) {
2084+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
2085+
20192086 table = 'nodb_vectorDbTable1' ;
20202087 const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
20212088 IntCol NUMBER,
@@ -2029,6 +2096,8 @@ describe('294. dataTypeVector1.js', function() {
20292096 } ) ; // 294.2.11
20302097
20312098 it ( '294.2.12 insert a uint8 vector with max 65528 dimensions to flex binary column' , async function ( ) {
2099+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
2100+
20322101 const arr = Array ( 8191 ) . fill ( 1 ) ;
20332102 const vecUint8 = new Uint8Array ( arr ) ;
20342103
@@ -2054,6 +2123,8 @@ describe('294. dataTypeVector1.js', function() {
20542123 } ) ; // 294.2.12
20552124
20562125 it ( '294.2.13 vector binary column with no multiple of eight dimensions' , async function ( ) {
2126+ if ( ! isVectorBinaryRunnable ) this . skip ( ) ;
2127+
20572128 table = 'nodb_vectorDbTable1' ;
20582129 const sql = `CREATE TABLE IF NOT EXISTS ${ table } (
20592130 IntCol NUMBER,
0 commit comments