Skip to content

Commit 46d3e08

Browse files
committed
Improvements in documentation, tests and examples
1 parent 4ae0a82 commit 46d3e08

23 files changed

+865
-520
lines changed

doc/src/_ext/table_with_summary.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2022, 2024, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -51,6 +51,28 @@ def run(self):
5151

5252
class HTMLTranslator(sphinx.writers.html5.HTML5Translator):
5353

54+
def visit_paragraph(self, node):
55+
text_to_hide = [
56+
"No optional parameters for this option value",
57+
"No required parameters for this option value",
58+
"No optional configuration for this option value",
59+
"No relevant notes"
60+
]
61+
children = node.children
62+
if len(children) == 1 and children[0].astext() in text_to_hide:
63+
atts = {
64+
"style": "clip: rect(1px, 1px, 1px, 1px);"
65+
"clip-path: inset(50%);"
66+
"height: 1px;"
67+
"overflow: hidden;"
68+
"position: absolute;"
69+
"white-space: nowrap;"
70+
"width: 1px;"
71+
}
72+
self.body.append(self.starttag(node, "p", "", **atts))
73+
else:
74+
super().visit_paragraph(node)
75+
5476
def visit_table(self, node):
5577
if version.parse(sphinx.__version__) > version.parse('4.2.0'):
5678
self._table_row_indices = [0]

doc/src/api_manual/oracledb.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,43 +208,43 @@ for common :ref:`Oracle Database Type Constants <oracledbconstantsdbtype>`.
208208
* - ``oracledb.BFILE``
209209
- 2020
210210
- ``oracledb.DB_TYPE_BFILE``
211-
-
211+
- No relevant notes
212212
* - ``oracledb.BLOB``
213213
- 2019
214214
- ``oracledb.DB_TYPE_BLOB``
215-
-
215+
- No relevant notes
216216
* - ``oracledb.BUFFER``
217217
- 2006
218218
- ``oracledb.DB_TYPE_RAW``
219-
-
219+
- No relevant notes
220220
* - ``oracledb.CLOB``
221221
- 2017
222222
- ``oracledb.DB_TYPE_CLOB``
223-
-
223+
- No relevant notes
224224
* - ``oracledb.CURSOR``
225225
- 2021
226226
- ``oracledb.DB_TYPE_CURSOR``
227-
-
227+
- No relevant notes
228228
* - ``oracledb.DATE``
229229
- 2014
230230
- ``oracledb.DB_TYPE_TIMESTAMP_LTZ``
231-
-
231+
- No relevant notes
232232
* - ``oracledb.DEFAULT``
233233
- 0
234234
- NA
235235
- Used with ``fetchInfo`` to reset the fetch type to the database type.
236236
* - ``oracledb.NUMBER``
237237
- 2010
238238
- ``oracledb.DB_TYPE_NUMBER``
239-
-
239+
- No relevant notes
240240
* - ``oracledb.NCLOB``
241241
- 2018
242242
- ``oracledb.DB_TYPE_NCLOB``
243243
- .. versionadded:: 4.2
244244
* - ``oracledb.STRING``
245245
- 2001
246246
- ``oracledb.DB_TYPE_VARCHAR``
247-
-
247+
- No relevant notes
248248

249249
.. _oracledbconstantsbinddir:
250250

doc/src/user_guide/connection_handling.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,7 +4189,7 @@ corresponding option values are listed in the table below.
41894189
- Optional Parameters for This Option Value
41904190
* - Default Azure Credential
41914191
- AZURE_DEFAULT (also used when the Authentication method is not set)
4192-
-
4192+
- No required parameters for this option value
41934193
- AZURE_CLIENT_ID
41944194
41954195
AZURE_CLIENT_SECRET
@@ -4206,19 +4206,19 @@ corresponding option values are listed in the table below.
42064206
AZURE_CLIENT_SECRET
42074207
42084208
AZURE_TENANT_ID
4209-
-
4209+
- No optional parameters for this option value
42104210
* - Service Principal with client certificate
42114211
- AZURE_SERVICE_PRINCIPAL
42124212
- AZURE_CLIENT_ID
42134213
42144214
AZURE_CLIENT_CERTIFICATE_PATH
42154215
42164216
AZURE_TENANT_ID
4217-
-
4217+
- No optional parameters for this option value
42184218
* - Managed Identity
42194219
- AZURE_MANAGED_IDENTITY
42204220
- AZURE_MANAGED_IDENTITY_CLIENT_ID - required only if user assigned
4221-
-
4221+
- No optional parameters for this option value
42224222
42234223
Note that the Azure service principal with client certificate overrides Azure
42244224
service principal with client secret.
@@ -4509,12 +4509,12 @@ corresponding option values are listed in the table below.
45094509
OCI_PROFILE_PATH
45104510
* - Instance Principal Authentication
45114511
- OCI_INSTANCE_PRINCIPAL
4512-
-
4513-
-
4512+
- No optional configuration for this option value
4513+
- No optional parameters for this option value
45144514
* - Resource Principal Authentication
45154515
- OCI_RESOURCE_PRINCIPAL
4516-
-
4517-
-
4516+
- No optional configuration for this option value
4517+
- No optional parameters for this option value
45184518
45194519
See `Authentication Parameters for OCI Object Storage <https://www.oracle.com/
45204520
pls/topic/lookup?ctx=dblatest&id=GUID-EB94F084-0F3F-47B5-AD77-D111070F7E8D>`__

examples/vectortype2.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ async function run() {
8787
let i = 0;
8888
const binds = [], num = 4;
8989
const expectedArrays = [
90-
[1, 2, 3],
9190
[4, 5, 6],
91+
[1, 2, 3],
9292
[42, 52, 613],
9393
[-1, -2, -3]
9494
];
@@ -116,13 +116,14 @@ async function run() {
116116

117117
// Calculate distance to a given embedding
118118
const vecQuery = new Float64Array([3, 1, 2]);
119-
let expectedValues = [6, 33, 377443, 50];
119+
let expectedValues = ['0.1167', '0.2143', '0.3915', '1.7857'];
120120
result = await connection.execute(
121121
`select vector_distance (embedding, :1) from ${tableName}`, [vecQuery]);
122122
console.log(`Distance from Input Embedding `, [3, 1, 2]);
123123
console.log(result.rows);
124+
console.log(result.rows[0]['VECTOR_DISTANCE(EMBEDDING,:1)']);
124125
for (i = 0; i < num; i++) {
125-
assert.deepStrictEqual(result.rows[i], {"VECTOR_DISTANCE(EMBEDDING,:1)": expectedValues[i]});
126+
assert.deepStrictEqual(result.rows[i]['VECTOR_DISTANCE(EMBEDDING,:1)'].toFixed(4), expectedValues[i]);
126127
}
127128

128129
// Calculate top 3 similarity search to a given embedding
@@ -133,35 +134,35 @@ async function run() {
133134
console.log(result.rows);
134135
assert.deepStrictEqual(result.rows[0].EMBEDDING, expectedArrays[0]);
135136
assert.deepStrictEqual(result.rows[1].EMBEDDING, expectedArrays[1]);
136-
assert.deepStrictEqual(result.rows[2].EMBEDDING, expectedArrays[3]);
137+
assert.deepStrictEqual(result.rows[2].EMBEDDING, expectedArrays[2]);
137138

138139
// Nearest Neighbours (distance < 34) for a given embedding [3,1,2]
139140
// gives [1,2,3] and [4,5,6]
140141
console.log('Nearest Neighbours with distance < 34:');
141142
result = await connection.execute(
142-
`select * from ${tableName} where vector_distance (embedding, vector('[3,1,2]', 3)) < 34 `);
143+
`select * from ${tableName} where vector_distance (embedding, vector('[3,1,2]', 3, float64)) < 34 `);
143144
console.log(result.rows);
144145
assert.deepStrictEqual(result.rows[0].EMBEDDING, expectedArrays[0]);
145146
assert.deepStrictEqual(result.rows[1].EMBEDDING, expectedArrays[1]);
146147

147148
// Cosine Distance
148149
result = await connection.execute(
149-
`select cosine_distance (embedding, vector('[3,1,2]', 3)) as cosdistance from ${tableName}`);
150-
expectedValues = [0.2142857142857143, 0.11673988938389968, 0.3914785344302253, 1.7857142857142856];
150+
`select cosine_distance (embedding, vector('[3,1,2]', 3, float64)) as cosdistance from ${tableName}`);
151+
expectedValues = ['0.1167', '0.2143', '0.3915', '1.7857'];
151152
for (i = 0; i < num; i++) {
152-
assert.deepStrictEqual(result.rows[i], {"COSDISTANCE": expectedValues[i]});
153+
assert.deepStrictEqual(result.rows[i]['COSDISTANCE'].toFixed(4), expectedValues[i]);
153154
}
154155
console.log(`Cosine Distance from Input Embedding `, [3, 1, 2]);
155156
console.log(result.rows);
156157

157158
// inner product
158159
result = await connection.execute(
159-
`select inner_product (embedding, vector('[3,1,2]', 3)) from ${tableName}`);
160+
`select inner_product (embedding, vector('[3,1,2]', 3, float64)) from ${tableName}`);
160161
console.log(`Inner product with Input Embedding `, [3, 1, 2]);
161162
console.log(result.rows);
162-
expectedValues = [11, 29, 1404, -11];
163+
expectedValues = [29, 11, 1404, -11];
163164
for (i = 0; i < num; i++) {
164-
assert.deepStrictEqual(result.rows[i], {"INNER_PRODUCT(EMBEDDING,VECTOR('[3,1,2]',3))": expectedValues[i]});
165+
assert.deepStrictEqual(result.rows[i], {"INNER_PRODUCT(EMBEDDING,VECTOR('[3,1,2]',3,FLOAT64))": expectedValues[i]});
165166
}
166167
} catch (err) {
167168
console.error(err);

test/dataTypeVector1.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ describe('294. dataTypeVector1.js', function() {
396396
}); // 294.13
397397

398398
it('294.14 insert uint8 typed array to float64 vector column', async function() {
399+
if (!isVectorBinaryRunnable) this.skip();
400+
399401
// Create an UInt8Array
400402
const uInt8Arr = new Uint8Array([3, 2, 3, 4, 5, 6, 3, 4, 5, 5]);
401403
// Bind the UInt8Array using oracledb.DB_TYPE_VECTOR
@@ -417,6 +419,8 @@ describe('294. dataTypeVector1.js', function() {
417419
}); // 294.14
418420

419421
it('294.15 insert uint8arr typed array to flex vector column', async function() {
422+
if (!isVectorBinaryRunnable) this.skip();
423+
420424
// Create an UInt8Array
421425
const uInt8Arr = new Uint8Array([126, 125, -126, -23, 11, 12, -11, -12, 10, 10]);
422426

@@ -434,6 +438,8 @@ describe('294. dataTypeVector1.js', function() {
434438
}); // 294.15
435439

436440
it('294.16 insert uInt8arr typed array to float32 vector column', async function() {
441+
if (!isVectorBinaryRunnable) this.skip();
442+
437443
// Create an UInt8Array
438444
const Uint8arr = new Uint8Array([3]);
439445

test/dataTypeVector2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('295. dataTypeVector2.js', function() {
7979
});
8080

8181
beforeEach(async function() {
82-
await connection.execute(`TRUNCATE TABLE ${tableName}`);
82+
await connection.execute(`DELETE FROM ${tableName}`);
8383
oracledb.fetchTypeHandler = function(metadata) {
8484
if (metadata.dbType === oracledb.DB_TYPE_VECTOR) {
8585
const myConverter = (v) => {

0 commit comments

Comments
 (0)