Skip to content

Commit b5d4bb4

Browse files
committed
Eliminate NJS-058 when explicitly binding string/buffer to LOB types
1 parent 8cc6419 commit b5d4bb4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
- Added missing support for binding as `oracledb.DB_TYPE_BINARY_INTEGER`.
1616

17+
- Fixed binding string or buffer data when explicitly specifying the type as
18+
`oracledb.DB_TYPE_BLOB`, `oracledb.DB_TYPE_CLOB` or `oracledb.DB_TYPE_NCLOB`.
19+
1720
## node-oracledb v5.3.0 (22 Oct 2021)
1821

1922
- Added a

src/njsVariable.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -1032,7 +1032,9 @@ static bool njsVariable_setFromString(njsVariable *var, uint32_t pos,
10321032
&bufferLength))
10331033

10341034
// check size, if applicable
1035-
if (checkSize && bufferLength > var->maxSize)
1035+
if (checkSize && var->varTypeNum != DPI_ORACLE_TYPE_CLOB &&
1036+
var->varTypeNum != DPI_ORACLE_TYPE_NCLOB &&
1037+
bufferLength > var->maxSize)
10361038
return njsBaton_setError(baton, errMaxSizeTooSmall, var->maxSize,
10371039
bufferLength, pos);
10381040

@@ -1193,7 +1195,8 @@ bool njsVariable_setScalarValue(njsVariable *var, uint32_t pos, napi_env env,
11931195
return njsVariable_setInvalidBind(var, pos, baton);
11941196
NJS_CHECK_NAPI(env, napi_get_buffer_info(env, value, &buffer,
11951197
&bufferLength))
1196-
if (checkSize && bufferLength > var->maxSize)
1198+
if (checkSize && var->varTypeNum == DPI_ORACLE_TYPE_RAW &&
1199+
bufferLength > var->maxSize)
11971200
return njsBaton_setError(baton, errMaxSizeTooSmall,
11981201
var->maxSize, bufferLength, pos);
11991202
if (dpiVar_setFromBytes(var->dpiVarHandle, pos, buffer,

0 commit comments

Comments
 (0)