Rename lob.getValue() to lob.getData()
This commit is contained in:
parent
61bd19a4e2
commit
8ea69fddb1
|
@ -26,8 +26,8 @@
|
|||
returned from PL/SQL without needing parameters or bind variables.
|
||||
|
||||
- Added
|
||||
[`lob.getValue()`](https://oracle.github.io/node-oracledb/doc/api.html#lobgetvalue)
|
||||
to return a LOBs value from a Lob instance.
|
||||
[`lob.getData()`](https://oracle.github.io/node-oracledb/doc/api.html#lobgetdata)
|
||||
to return a LOBs data from a Lob instance.
|
||||
|
||||
- Class methods are now configurable. For example via
|
||||
`Object.defineProperty`.
|
||||
|
|
14
doc/api.md
14
doc/api.md
|
@ -218,7 +218,7 @@ limitations under the License.
|
|||
- 6.1.4 [`type`](#proplobtype)
|
||||
- 6.2 [Lob Methods](#lobmethods)
|
||||
- 6.2.1 [`close()`](#lobclose)
|
||||
- 6.2.2 [`getValue()`](#lobgetvalue)
|
||||
- 6.2.2 [`getData()`](#lobgetdata)
|
||||
7. [Pool Class](#poolclass)
|
||||
- 7.1 [Pool Properties](#poolproperties)
|
||||
- 7.1.1 [`connectionsInUse`](#proppoolconnectionsinuse)
|
||||
|
@ -4216,18 +4216,18 @@ See [Closing Lobs](#closinglobs) for more discussion.
|
|||
*Error error* | If `close()` succeeds, `error` is NULL. If an error occurs, then `error` contains the [error message](#errorobj).
|
||||
|
||||
|
||||
#### <a name="lobgetvalue"></a> 6.2.2 `lob.getValue()`
|
||||
#### <a name="lobgetdata"></a> 6.2.2 `lob.getData()`
|
||||
|
||||
##### Prototype
|
||||
|
||||
Callback:
|
||||
```
|
||||
getValue(function(Error error, String data));
|
||||
getValue(function(Error error, Buffer data));
|
||||
getData(function(Error error, String data));
|
||||
getData(function(Error error, Buffer data));
|
||||
```
|
||||
Promise:
|
||||
```
|
||||
promise = getValue();
|
||||
promise = getData();
|
||||
```
|
||||
|
||||
##### Description
|
||||
|
@ -4239,7 +4239,7 @@ to 1 GB in length.
|
|||
For queries returning LOB columns, it can be more efficient to use
|
||||
[`fetchAsString`](#propdbfetchasstring),
|
||||
[`fetchAsBuffer`](#propdbfetchasbuffer), or
|
||||
[`fetchInfo`](#executeoptions) instead of `lob.getValue()`.
|
||||
[`fetchInfo`](#executeoptions) instead of `lob.getData()`.
|
||||
|
||||
This method was added in node-oracledb 4.0.
|
||||
|
||||
|
@ -4253,7 +4253,7 @@ This method was added in node-oracledb 4.0.
|
|||
|
||||
Callback function parameter | Description
|
||||
----------------------------|-------------
|
||||
*Error error* | If `getValue()` succeeds, `error` is NULL. If an error occurs, then `error` contains the [error message](#errorobj).
|
||||
*Error error* | If `getData()` succeeds, `error` is NULL. If an error occurs, then `error` contains the [error message](#errorobj).
|
||||
*String data* or *Buffer data* | The value of the LOB.
|
||||
|
||||
## <a name="poolclass"></a> 7. Pool Class
|
||||
|
|
|
@ -46,10 +46,10 @@ function close(closeCb) {
|
|||
}
|
||||
|
||||
|
||||
function getValue(getValueCb) {
|
||||
function getData(getDataCb) {
|
||||
nodbUtil.assert(arguments.length === 1, 'NJS-009');
|
||||
nodbUtil.assert(typeof getValueCb === 'function', 'NJS-005', 1);
|
||||
this._getValue(getValueCb);
|
||||
nodbUtil.assert(typeof getDataCb === 'function', 'NJS-005', 1);
|
||||
this._getData(getDataCb);
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Lob {
|
|||
_extend(oracledb) {
|
||||
this._oracledb = oracledb;
|
||||
this.close = nodbUtil.promisify(oracledb, close);
|
||||
this.getValue = nodbUtil.promisify(oracledb, getValue);
|
||||
this.getData = nodbUtil.promisify(oracledb, getData);
|
||||
}
|
||||
|
||||
// implementation of streaming read; if lob is set to auto-close, the lob is
|
||||
|
|
29
src/njsLob.c
29
src/njsLob.c
|
@ -27,18 +27,18 @@
|
|||
|
||||
// class methods
|
||||
static NJS_NAPI_METHOD(njsLob_close);
|
||||
static NJS_NAPI_METHOD(njsLob_getValue);
|
||||
static NJS_NAPI_METHOD(njsLob_getData);
|
||||
static NJS_NAPI_METHOD(njsLob_read);
|
||||
static NJS_NAPI_METHOD(njsLob_write);
|
||||
|
||||
// asynchronous methods
|
||||
static NJS_ASYNC_METHOD(njsLob_closeAsync);
|
||||
static NJS_ASYNC_METHOD(njsLob_getValueAsync);
|
||||
static NJS_ASYNC_METHOD(njsLob_getDataAsync);
|
||||
static NJS_ASYNC_METHOD(njsLob_readAsync);
|
||||
static NJS_ASYNC_METHOD(njsLob_writeAsync);
|
||||
|
||||
// post asynchronous methods
|
||||
static NJS_ASYNC_POST_METHOD(njsLob_getValuePostAsync);
|
||||
static NJS_ASYNC_POST_METHOD(njsLob_getDataPostAsync);
|
||||
static NJS_ASYNC_POST_METHOD(njsLob_readPostAsync);
|
||||
|
||||
// processing arguments methods
|
||||
|
@ -62,8 +62,7 @@ static NJS_NAPI_FINALIZE(njsLob_finalize);
|
|||
// properties defined by the class
|
||||
static const napi_property_descriptor njsClassProperties[] = {
|
||||
{ "_close", NULL, njsLob_close, NULL, NULL, NULL, napi_default, NULL },
|
||||
{ "_getValue", NULL, njsLob_getValue, NULL, NULL, NULL, napi_default,
|
||||
NULL },
|
||||
{ "_getData", NULL, njsLob_getData, NULL, NULL, NULL, napi_default, NULL },
|
||||
{ "__read", NULL, njsLob_read, NULL, NULL, NULL, napi_default, NULL },
|
||||
{ "__write", NULL, njsLob_write, NULL, NULL, NULL, napi_default, NULL },
|
||||
{ "_autoCloseLob", NULL, NULL, njsLob_getAutoCloseLob, NULL, NULL,
|
||||
|
@ -264,30 +263,30 @@ static napi_value njsLob_getValid(napi_env env, napi_callback_info info)
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// njsLob_getValue()
|
||||
// njsLob_getData()
|
||||
// Read all of the data from the LOB and return it as a single string or
|
||||
// buffer.
|
||||
//
|
||||
// PARAMETERS
|
||||
// - JS callback which will receive (error, data)
|
||||
//-----------------------------------------------------------------------------
|
||||
static napi_value njsLob_getValue(napi_env env, napi_callback_info info)
|
||||
static napi_value njsLob_getData(napi_env env, napi_callback_info info)
|
||||
{
|
||||
njsBaton *baton;
|
||||
|
||||
if (!njsLob_createBaton(env, info, 1, NULL, &baton))
|
||||
return NULL;
|
||||
njsBaton_queueWork(baton, env, "GetValue", njsLob_getValueAsync,
|
||||
njsLob_getValuePostAsync, 2);
|
||||
njsBaton_queueWork(baton, env, "GetData", njsLob_getDataAsync,
|
||||
njsLob_getDataPostAsync, 2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// njsLob_getValueAsync()
|
||||
// Worker function for njsLob_getValue().
|
||||
// njsLob_getDataAsync()
|
||||
// Worker function for njsLob_getData().
|
||||
//-----------------------------------------------------------------------------
|
||||
static bool njsLob_getValueAsync(njsBaton *baton)
|
||||
static bool njsLob_getDataAsync(njsBaton *baton)
|
||||
{
|
||||
njsLob *lob = (njsLob*) baton->callingInstance;
|
||||
bool ok = true;
|
||||
|
@ -327,10 +326,10 @@ static bool njsLob_getValueAsync(njsBaton *baton)
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// njsLob_getValuePostAsync()
|
||||
// Generates return values for njsLob_getValue().
|
||||
// njsLob_getDataPostAsync()
|
||||
// Generates return values for njsLob_getData().
|
||||
//-----------------------------------------------------------------------------
|
||||
static bool njsLob_getValuePostAsync(njsBaton *baton, napi_env env,
|
||||
static bool njsLob_getDataPostAsync(njsBaton *baton, napi_env env,
|
||||
napi_value *args)
|
||||
{
|
||||
njsLob *lob = (njsLob*) baton->callingInstance;
|
||||
|
|
|
@ -202,7 +202,7 @@ describe('41. dataTypeBlob.js', function() {
|
|||
], done);
|
||||
}); // 41.1.1
|
||||
|
||||
it('41.1.2 BLOB getValue()', function(done) {
|
||||
it('41.1.2 BLOB getData()', function(done) {
|
||||
connection.should.be.ok();
|
||||
async.series([
|
||||
function blobinsert1(callback) {
|
||||
|
@ -252,7 +252,7 @@ describe('41. dataTypeBlob.js', function() {
|
|||
|
||||
fs.readFile( inFileName, function(err, data) {
|
||||
should.not.exist(err);
|
||||
lob.getValue(function(err, blob) {
|
||||
lob.getData(function(err, blob) {
|
||||
data.length.should.be.exactly(blob.length);
|
||||
data.should.eql(blob);
|
||||
callback();
|
||||
|
|
|
@ -231,7 +231,7 @@ describe('40. dataTypeClob.js', function() {
|
|||
}); // 40.1.1
|
||||
|
||||
|
||||
it('40.1.2 CLOB getValue()', function(done) {
|
||||
it('40.1.2 CLOB getData()', function(done) {
|
||||
connection.should.be.ok();
|
||||
async.series([
|
||||
function clobinsert1(callback) {
|
||||
|
@ -280,7 +280,7 @@ describe('40. dataTypeClob.js', function() {
|
|||
|
||||
fs.readFile( inFileName, { encoding: 'utf8' }, function(err, data) {
|
||||
should.not.exist(err);
|
||||
lob.getValue(function(err, clob) {
|
||||
lob.getData(function(err, clob) {
|
||||
should.not.exist(err);
|
||||
data.length.should.be.exactly(clob.length);
|
||||
data.should.equal(clob);
|
||||
|
|
|
@ -696,14 +696,14 @@ Overview of node-oracledb functional tests
|
|||
40. dataTypeClob.js
|
||||
40.1 testing CLOB data type
|
||||
40.1.1 stores CLOB value correctly
|
||||
40.1.2 CLOB getValue()
|
||||
40.1.2 CLOB getData()
|
||||
40.2 stores null value correctly
|
||||
40.2.1 testing Null, Empty string and Undefined
|
||||
|
||||
41. dataTypeBlob.js
|
||||
41.1 testing BLOB data type
|
||||
41.1.1 stores BLOB value correctly
|
||||
41.1.2 BLOB getValue()
|
||||
41.1.2 BLOB getData()
|
||||
41.2 stores null value correctly
|
||||
41.2.1 testing Null, Empty string and Undefined
|
||||
|
||||
|
|
Loading…
Reference in New Issue