Skip to content

Commit a8658f0

Browse files
committed
Thin mode support and new examples
1 parent 310203d commit a8658f0

File tree

187 files changed

+16250
-1615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+16250
-1615
lines changed

.npmignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.github
22
.nycrc
3+
.gitattributes
34
.gitmodules
45
.eslintrc
56
INSTALL.md
@@ -8,7 +9,9 @@ Makefile
89
Makefile.win32
910
*.tgz
1011
/doc
11-
/examples
12+
/examples/*
13+
!/examples/example.js
14+
!/examples/dbconfig.js
1215
/test
1316
/build/Release/oracledb.node
1417
/build/oracledb.target.mk
@@ -33,6 +36,5 @@ Makefile.win32
3336
/odpi/test
3437
/odpi/.git
3538
/odpi/.github
36-
/odpi/.gitattributes
3739
/odpi/util
3840
\#*

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# node-oracledb version 6.0.0-dev
1+
# node-oracledb version 6.0.0-dev6
22

33
**This release is under development and information may be incomplete**
44

55
The node-oracledb add-on for Node.js powers high performance Oracle Database
66
applications. Applications can be written in TypeScript, or directly in
77
JavaScript.
88

9-
Use node-oracledb 6.0.0-dev to connect Node.js 14.6, or later, to Oracle
9+
Use node-oracledb 6.0.0-dev6 to connect Node.js 14.6, or later, to Oracle
1010
Database. Older versions of node-oracledb may work with older versions of
1111
Node.js.
1212

doc/src/release_notes.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,33 @@ node-oracledb `v6.0.0 <https://github.com/oracle/node-oracledb/compare/v5.5.0...
1010

1111
**This release is under development**
1212

13+
#) node-oracledb is now a 'Thin' driver by default that connects directly
14+
to Oracle Database. Optional use of Oracle Client libraries enables a
15+
:ref:`'Thick' mode <enablingthick>` with some additional functionality.
16+
17+
#) Added a new ``oracledb.fetchTypeHandler`` and equivalent execution option
18+
allowing a user function to be specified that can make custom alterations
19+
to SQL query data before it is returned to the app.
20+
21+
#) Deprecated execution option attribute ``fetchInfo``. Use the new
22+
``fetchTypeHandler`` functionality instead.
23+
24+
#) Changed ``oracledb.DB_TYPE_*`` constants to be ``DbType`` objects
25+
instead of numbers.
26+
27+
#) Added support for the Oracle Database 23c BOOLEAN SQL type.
28+
1329
#) Bumped the minimum Node.js version required to 14.6 so Node-API version 6
1430
and ``FinalizationRegistry`` can be used in the driver implementation.
1531

16-
#) Re-licensed to dual Apache 2.0 or UPL 1.0 licenses, see `LICENSE.txt
17-
<https://github.com/oracle/node-oracledb/blob/main/LICENSE.txt>`__.
32+
#) Allow ``package/prunebinaries.js`` to optionally remove all the Thick mode
33+
binaries to enable a Thin-mode only installation.
34+
35+
#) Allow ``npm run buildpackage`` to create a package without Thick mode
36+
binaries.
37+
38+
#) Re-licensed to dual Apache 2.0 or UPL 1.0 licenses, see
39+
`LICENSE.txt <https://github.com/oracle/node-oracledb/blob/main/LICENSE.txt>`__.
1840

1941
#) Internal change: reorganized code to move functionality from C to JavaScript.
2042

examples/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
# Node-oracledb Examples
22

3-
This directory contains [node-oracledb](https://www.npmjs.com/package/oracledb)
3+
The directory in node-oracledb's [Github repository](https://github.com/oracle/node-oracledb/tree/main/examples) contains a lot of [node-oracledb](https://www.npmjs.com/package/oracledb)
44
examples. Documentation is
55
[here](https://node-oracledb.readthedocs.io/en/latest/).
66

77
To run the examples:
88

99
- [Install node-oracledb](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html#quickstart).
1010

11-
- Edit `dbconfig.js` and set your username and the database connection string,
12-
for example:
11+
- Ensure that you navigate to the `examples` directory in your terminal window
12+
or IDE, where you are running the samples.
1313

14-
```
15-
module.exports = {
16-
user: "hr",
17-
password: process.env.NODE_ORACLEDB_PASSWORD,
18-
connectString:"localhost/orclpdb1"
19-
};
20-
21-
```
22-
23-
- In a terminal window, set the environment variable `NODE_ORACLEDB_PASSWORD` to
24-
the value of your database password.
14+
- Review `dbconfig.js`. In your terminal window or IDE, set the environment
15+
variables. For example, set `NODE_ORACLEDB_PASSWORD` to the value of your
16+
database password.
2517

2618
- Review the samples and then run them individually. For example, to see what
2719
the file `example.js` does, use:
@@ -37,6 +29,11 @@ To run the examples:
3729
node demodrop.js
3830
```
3931

32+
Many examples can be run in either node-oracledb Thin (the default) or Thick
33+
modes. Thin mode is a pure JavaScript implementation of node-oracledb.
34+
Setting the environment variable `NODE_ORACLEDB_DRIVER_MODE` to `'thick'` will
35+
change node-oracledb to use Thick mode.
36+
4037
## Example Overview
4138

4239
If this is your first time with node-oracledb, start with
@@ -70,7 +67,6 @@ File Name | Description
7067
[`em_rowcounts.js`](em_rowcounts.js) | `executeMany()` example showing how to find the number of rows affected by each input row
7168
[`endtoend.js`](endtoend.js) | Example showing setting tracing attributes
7269
[`example.js`](example.js) | Basic example showing creating a table, inserting multiple rows, and querying rows
73-
[`fetchinfo.js`](fetchinfo.js) | Show how numbers and dates can be returned as strings using `fetchAsString` and `fetchInfo`
7470
[`impres.js`](impres.js) | Shows PL/SQL 'Implict Results' returning multiple query results from PL/SQL code.
7571
[`insert1.js`](insert1.js) | Basic example creating a table and inserting data. Shows DDL and DML
7672
[`insert2.js`](insert2.js) | Basic example showing auto commit behavior
@@ -83,6 +79,7 @@ File Name | Description
8379
[`lobselect.js`](lobselect.js) | Shows basic, non-streaming CLOB and BLOB queries
8480
[`lobstream1.js`](lobstream1.js) | Shows how to stream LOBs to files
8581
[`lobstream2.js`](lobstream2.js) | Shows using Stream data events to fetch a CLOB
82+
[`lowercasecolumns.js`](lowercasecolumns.js) | Shows how a type handler can convert column names to lower case
8683
[`metadata.js`](metadata.js) | Shows the metadata available after executing SELECT statements
8784
[`plsqlarray.js`](plsqlarray.js) | Examples of binding PL/SQL "INDEX BY" tables
8885
[`plsqlfunc.js`](plsqlfunc.js) | How to call a PL/SQL function
@@ -109,5 +106,7 @@ File Name | Description
109106
[`sessiontagging1.js`](sessiontagging1.js) | Simple pooled connection tagging for setting session state
110107
[`sessiontagging2.js`](sessiontagging2.js) | More complex example of pooled connection tagging for setting session state
111108
[`soda1.js`](soda1.js) | Basic Simple Oracle Document Access (SODA) example
109+
[`typehandlerdate.js`](typehandlerdate.js) | Show how a type handler can format a queried date in a locale-specific way
110+
[`typehandlernum.js`](typehandlernum.js) | Show how a type handler can format a queried number in a locale-specific way
112111
[`version.js`](version.js) | Shows the node-oracledb version attributes
113112
[`webapp.js`](webapp.js) | A simple web application using a connection pool

examples/aqmulti.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,32 @@
3131
* Before running this, a queue allowing RAW payloads must be
3232
* created, see https://node-oracledb.readthedocs.io/en/latest/user_guide/aq.html#aqrawexample
3333
*
34-
* This example requires node-oracledb 4 or later.
35-
*
36-
* This example uses Node 8's async/await syntax.
37-
*
3834
*****************************************************************************/
3935

40-
const fs = require('fs');
36+
'use strict';
37+
38+
Error.stackTraceLimit = 50;
39+
4140
const oracledb = require('oracledb');
4241
const dbConfig = require('./dbconfig.js');
4342

44-
// On Windows and macOS, you can specify the directory containing the Oracle
45-
// Client Libraries at runtime, or before Node.js starts. On other platforms
46-
// the system library search path must always be set before Node.js is started.
47-
// See the node-oracledb installation documentation.
48-
// If the search path is not correct, you will get a DPI-1047 error.
49-
let libPath;
50-
if (process.platform === 'win32') { // Windows
51-
libPath = 'C:\\oracle\\instantclient_19_12';
52-
} else if (process.platform === 'darwin') { // macOS
53-
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
54-
}
55-
if (libPath && fs.existsSync(libPath)) {
56-
oracledb.initOracleClient({ libDir: libPath });
43+
44+
// This example requires node-oracledb Thick mode.
45+
//
46+
// Thick mode requires Oracle Client or Oracle Instant Client libraries. On
47+
// Windows and macOS Intel you can specify the directory containing the
48+
// libraries at runtime or before Node.js starts. On other platforms (where
49+
// Oracle libraries are available) the system library search path must always
50+
// include the Oracle library path before Node.js starts. If the search path
51+
// is not correct, you will get a DPI-1047 error. See the node-oracledb
52+
// installation documentation.
53+
let clientOpts = {};
54+
if (process.platform === 'win32') { // Windows
55+
clientOpts = { libDir: 'C:\\oracle\\instantclient_19_17' };
56+
} else if (process.platform === 'darwin' && process.arch === 'x64') { // macOS Intel
57+
clientOpts = { libDir: process.env.HOME + '/Downloads/instantclient_19_8' };
5758
}
59+
oracledb.initOracleClient(clientOpts); // enable node-oracledb Thick mode
5860

5961
const queueName = "DEMO_RAW_QUEUE";
6062

@@ -66,7 +68,7 @@ async function enq() {
6668
const queue = await connection.getQueue(queueName);
6769
queue.enqOptions.visibility = oracledb.AQ_VISIBILITY_IMMEDIATE; // Send a message without requiring a commit
6870

69-
console.log('Enqueuing messages');
71+
console.log('Enqueuing 4 messages');
7072

7173
const messages = [
7274
"Message 1",

examples/aqobject.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,31 @@
3232
* payload must be created, see
3333
* https://node-oracledb.readthedocs.io/en/latest/user_guide/aq.html#aqobjexample
3434
*
35-
* This example requires node-oracledb 4 or later.
36-
*
37-
* This example uses Node 8's async/await syntax.
38-
*
3935
*****************************************************************************/
4036

41-
const fs = require('fs');
37+
'use strict';
38+
39+
Error.stackTraceLimit = 50;
40+
4241
const oracledb = require('oracledb');
4342
const dbConfig = require('./dbconfig.js');
4443

45-
// On Windows and macOS, you can specify the directory containing the Oracle
46-
// Client Libraries at runtime, or before Node.js starts. On other platforms
47-
// the system library search path must always be set before Node.js is started.
48-
// See the node-oracledb installation documentation.
49-
// If the search path is not correct, you will get a DPI-1047 error.
50-
let libPath;
51-
if (process.platform === 'win32') { // Windows
52-
libPath = 'C:\\oracle\\instantclient_19_12';
53-
} else if (process.platform === 'darwin') { // macOS
54-
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
55-
}
56-
if (libPath && fs.existsSync(libPath)) {
57-
oracledb.initOracleClient({ libDir: libPath });
44+
// This example requires node-oracledb Thick mode.
45+
//
46+
// Thick mode requires Oracle Client or Oracle Instant Client libraries. On
47+
// Windows and macOS Intel you can specify the directory containing the
48+
// libraries at runtime or before Node.js starts. On other platforms (where
49+
// Oracle libraries are available) the system library search path must always
50+
// include the Oracle library path before Node.js starts. If the search path
51+
// is not correct, you will get a DPI-1047 error. See the node-oracledb
52+
// installation documentation.
53+
let clientOpts = {};
54+
if (process.platform === 'win32') { // Windows
55+
clientOpts = { libDir: 'C:\\oracle\\instantclient_19_17' };
56+
} else if (process.platform === 'darwin' && process.arch === 'x64') { // macOS Intel
57+
clientOpts = { libDir: process.env.HOME + '/Downloads/instantclient_19_8' };
5858
}
59+
oracledb.initOracleClient(clientOpts); // enable node-oracledb Thick mode
5960

6061
const queueName = "ADDR_QUEUE";
6162

examples/aqoptions.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,31 @@
3131
* Before running this, a queue allowing RAW payloads must be created, see
3232
* https://node-oracledb.readthedocs.io/en/latest/user_guide/aq.html#aqrawexample
3333
*
34-
* This example requires node-oracledb 4 or later.
35-
*
36-
* This example uses Node 8's async/await syntax.
37-
*
3834
*****************************************************************************/
3935

40-
const fs = require('fs');
36+
'use strict';
37+
38+
Error.stackTraceLimit = 50;
39+
4140
const oracledb = require('oracledb');
4241
const dbConfig = require('./dbconfig.js');
4342

44-
// On Windows and macOS, you can specify the directory containing the Oracle
45-
// Client Libraries at runtime, or before Node.js starts. On other platforms
46-
// the system library search path must always be set before Node.js is started.
47-
// See the node-oracledb installation documentation.
48-
// If the search path is not correct, you will get a DPI-1047 error.
49-
let libPath;
50-
if (process.platform === 'win32') { // Windows
51-
libPath = 'C:\\oracle\\instantclient_19_12';
52-
} else if (process.platform === 'darwin') { // macOS
53-
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
54-
}
55-
if (libPath && fs.existsSync(libPath)) {
56-
oracledb.initOracleClient({ libDir: libPath });
43+
// This example requires node-oracledb Thick mode.
44+
//
45+
// Thick mode requires Oracle Client or Oracle Instant Client libraries. On
46+
// Windows and macOS Intel you can specify the directory containing the
47+
// libraries at runtime or before Node.js starts. On other platforms (where
48+
// Oracle libraries are available) the system library search path must always
49+
// include the Oracle library path before Node.js starts. If the search path
50+
// is not correct, you will get a DPI-1047 error. See the node-oracledb
51+
// installation documentation.
52+
let clientOpts = {};
53+
if (process.platform === 'win32') { // Windows
54+
clientOpts = { libDir: 'C:\\oracle\\instantclient_19_17' };
55+
} else if (process.platform === 'darwin' && process.arch === 'x64') { // macOS Intel
56+
clientOpts = { libDir: process.env.HOME + '/Downloads/instantclient_19_8' };
5757
}
58+
oracledb.initOracleClient(clientOpts); // enable node-oracledb Thick mode
5859

5960
const queueName = "DEMO_RAW_QUEUE";
6061

examples/aqraw.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,31 @@
3131
* Before running this, a queue allowing RAW payloads must be created, see
3232
* https://node-oracledb.readthedocs.io/en/latest/user_guide/aq.html#aqrawexample
3333
*
34-
* This example requires node-oracledb 4 or later.
35-
*
36-
* This example uses Node 8's async/await syntax.
37-
*
3834
*****************************************************************************/
3935

40-
const fs = require('fs');
36+
'use strict';
37+
38+
Error.stackTraceLimit = 50;
39+
4140
const oracledb = require('oracledb');
4241
const dbConfig = require('./dbconfig.js');
4342

44-
// On Windows and macOS, you can specify the directory containing the Oracle
45-
// Client Libraries at runtime, or before Node.js starts. On other platforms
46-
// the system library search path must always be set before Node.js is started.
47-
// See the node-oracledb installation documentation.
48-
// If the search path is not correct, you will get a DPI-1047 error.
49-
let libPath;
50-
if (process.platform === 'win32') { // Windows
51-
libPath = 'C:\\oracle\\instantclient_19_12';
52-
} else if (process.platform === 'darwin') { // macOS
53-
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
54-
}
55-
if (libPath && fs.existsSync(libPath)) {
56-
oracledb.initOracleClient({ libDir: libPath });
43+
// This example requires node-oracledb Thick mode.
44+
//
45+
// Thick mode requires Oracle Client or Oracle Instant Client libraries. On
46+
// Windows and macOS Intel you can specify the directory containing the
47+
// libraries at runtime or before Node.js starts. On other platforms (where
48+
// Oracle libraries are available) the system library search path must always
49+
// include the Oracle library path before Node.js starts. If the search path
50+
// is not correct, you will get a DPI-1047 error. See the node-oracledb
51+
// installation documentation.
52+
let clientOpts = {};
53+
if (process.platform === 'win32') { // Windows
54+
clientOpts = { libDir: 'C:\\oracle\\instantclient_19_17' };
55+
} else if (process.platform === 'darwin' && process.arch === 'x64') { // macOS Intel
56+
clientOpts = { libDir: process.env.HOME + '/Downloads/instantclient_19_8' };
5757
}
58+
oracledb.initOracleClient(clientOpts); // enable node-oracledb Thick mode
5859

5960
const queueName = "DEMO_RAW_QUEUE";
6061

0 commit comments

Comments
 (0)