2024-05-10 18:29:33 +08:00
|
|
|
/* Copyright (c) 2017, 2024, Oracle and/or its affiliates. */
|
2017-06-14 09:54:45 +08:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
2023-02-21 09:43:43 +08:00
|
|
|
* This software is dual-licensed to you under the Universal Permissive License
|
|
|
|
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
|
|
|
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
|
|
|
|
* either license.
|
2017-06-14 09:54:45 +08:00
|
|
|
*
|
2023-02-21 09:43:43 +08:00
|
|
|
* If you elect to accept the software under the Apache License, Version 2.0,
|
|
|
|
* the following applies:
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
2017-06-14 09:54:45 +08:00
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
2023-02-21 09:43:43 +08:00
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
2017-06-14 09:54:45 +08:00
|
|
|
*
|
2023-02-21 09:43:43 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2017-06-14 09:54:45 +08:00
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
* NAME
|
|
|
|
* 81. clobDMLBindAsString.js
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Testing CLOB binding as String with DML.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
'use strict';
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
const oracledb = require('oracledb');
|
|
|
|
const assert = require('assert');
|
|
|
|
const dbConfig = require('./dbconfig.js');
|
|
|
|
const random = require('./random.js');
|
2017-06-14 09:54:45 +08:00
|
|
|
|
|
|
|
describe('81. clobDMLBindAsString.js', function() {
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
let connection;
|
|
|
|
let insertID = 1; // assume id for insert into db starts from 1
|
2017-06-14 09:54:45 +08:00
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
const proc_clob_1 = "BEGIN \n" +
|
2017-06-14 09:54:45 +08:00
|
|
|
" DECLARE \n" +
|
|
|
|
" e_table_missing EXCEPTION; \n" +
|
|
|
|
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
|
|
|
" BEGIN \n" +
|
|
|
|
" EXECUTE IMMEDIATE('DROP TABLE nodb_dml_clob_1 PURGE'); \n" +
|
|
|
|
" EXCEPTION \n" +
|
|
|
|
" WHEN e_table_missing \n" +
|
|
|
|
" THEN NULL; \n" +
|
|
|
|
" END; \n" +
|
|
|
|
" EXECUTE IMMEDIATE (' \n" +
|
|
|
|
" CREATE TABLE nodb_dml_clob_1 ( \n" +
|
|
|
|
" id NUMBER, \n" +
|
|
|
|
" clob CLOB \n" +
|
|
|
|
" ) \n" +
|
|
|
|
" '); \n" +
|
|
|
|
"END; ";
|
2023-02-21 11:34:43 +08:00
|
|
|
const sql2DropTable1 = "DROP TABLE nodb_dml_clob_1 PURGE";
|
|
|
|
|
|
|
|
before(async function() {
|
|
|
|
connection = await oracledb.getConnection(dbConfig);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // before
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
after(async function() {
|
2023-02-21 15:02:10 +08:00
|
|
|
await connection.close();
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // after
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
const executeSQL = async function(sql) {
|
|
|
|
await connection.execute(sql);
|
2017-06-14 09:54:45 +08:00
|
|
|
};
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
const insertIntoClobTable1 = async function(id, content) {
|
|
|
|
let result = null;
|
2021-04-01 12:48:37 +08:00
|
|
|
if (content == "EMPTY_CLOB") {
|
2023-02-21 11:34:43 +08:00
|
|
|
result = await connection.execute(
|
2017-06-14 09:54:45 +08:00
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, EMPTY_CLOB())",
|
2023-02-21 11:34:43 +08:00
|
|
|
[ id ]);
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
2017-06-14 09:54:45 +08:00
|
|
|
} else {
|
2023-02-21 11:34:43 +08:00
|
|
|
result = await connection.execute(
|
2017-06-14 09:54:45 +08:00
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
2017-06-14 09:54:45 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
const updateClobTable1 = async function(id, content) {
|
|
|
|
let result = null;
|
2021-04-01 12:48:37 +08:00
|
|
|
if (content == "EMPTY_CLOB") {
|
2023-02-21 11:34:43 +08:00
|
|
|
result = await connection.execute(
|
2017-06-14 09:54:45 +08:00
|
|
|
"UPDATE nodb_dml_clob_1 set clob = EMPTY_CLOB() where id = :ID",
|
2023-02-21 11:34:43 +08:00
|
|
|
{ ID: id });
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
2017-06-14 09:54:45 +08:00
|
|
|
} else {
|
2023-02-21 11:34:43 +08:00
|
|
|
result = await connection.execute(
|
2017-06-14 09:54:45 +08:00
|
|
|
"UPDATE nodb_dml_clob_1 set clob = :C where id = :ID",
|
2023-02-21 11:34:43 +08:00
|
|
|
{ ID: id, C: content });
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
2017-06-14 09:54:45 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// compare the inserted clob with orginal content
|
2023-02-21 11:34:43 +08:00
|
|
|
const verifyClobValueWithString = async function(selectSql, originalString, specialStr) {
|
|
|
|
let result = null;
|
|
|
|
result = await connection.execute(selectSql);
|
|
|
|
const lob = result.rows[0][0];
|
|
|
|
|
|
|
|
if (originalString == '' || originalString == undefined || originalString == null) {
|
|
|
|
assert.ifError(lob);
|
|
|
|
} else {
|
|
|
|
assert(lob);
|
|
|
|
// set the encoding so we get a 'string' not a 'buffer'
|
|
|
|
lob.setEncoding('utf8');
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
let clobData = '';
|
|
|
|
|
|
|
|
lob.on('data', function(chunk) {
|
|
|
|
clobData += chunk;
|
|
|
|
});
|
|
|
|
|
|
|
|
lob.on('error', function(err) {
|
|
|
|
assert.ifError(err, "lob.on 'error' event.");
|
|
|
|
reject(err);
|
|
|
|
});
|
|
|
|
|
|
|
|
lob.on('end', function(err) {
|
|
|
|
assert.ifError(err);
|
|
|
|
if (originalString == "EMPTY_CLOB") {
|
|
|
|
assert.strictEqual(clobData, "");
|
|
|
|
} else {
|
|
|
|
const resultLength = clobData.length;
|
|
|
|
const specStrLength = specialStr.length;
|
|
|
|
assert.strictEqual(resultLength, originalString.length);
|
|
|
|
assert.strictEqual(clobData.substring(0, specStrLength), specialStr);
|
|
|
|
assert.strictEqual(clobData.substring(resultLength - specStrLength, resultLength), specialStr);
|
|
|
|
}
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
2017-06-14 09:54:45 +08:00
|
|
|
};
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
const checkInsertResult = async function(id, content, specialStr) {
|
|
|
|
const sql = "select clob from nodb_dml_clob_1 where id = " + id;
|
|
|
|
await verifyClobValueWithString(sql, content, specialStr);
|
2017-06-14 09:54:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('81.1 CLOB, INSERT', function() {
|
2023-02-21 11:34:43 +08:00
|
|
|
before(async function() {
|
|
|
|
await executeSQL(proc_clob_1);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // before
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
after(async function() {
|
|
|
|
await executeSQL(sql2DropTable1);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // after
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.1 works with EMPTY_CLOB', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = "EMPTY_CLOB";
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.1
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.2 works with empty string', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = '';
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.2
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.3 works with empty string and bind in maxSize set to 32767', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = "";
|
|
|
|
const result = await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: 32767 }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.3
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.4 works with empty string and bind in maxSize set to 50000', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = "";
|
|
|
|
const result = await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: 50000 }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.4
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.5 works with undefined', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = undefined;
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.5
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.6 works with null', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = null;
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.6
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.7 works with null and bind in maxSize set to 32767', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = null;
|
|
|
|
const result = await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: 32767 }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
2017-06-14 09:54:45 +08:00
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
await checkInsertResult(id, content, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.7
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.8 works with null and bind in maxSize set to 50000', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = null;
|
|
|
|
const result = await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: 50000 }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
|
|
|
await checkInsertResult(id, content, null);
|
|
|
|
}); // 81.1.8
|
2017-06-14 09:54:45 +08:00
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.9 works with NaN', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = NaN;
|
2023-02-21 11:45:10 +08:00
|
|
|
await assert.rejects(
|
2023-02-21 11:34:43 +08:00
|
|
|
async () => {
|
|
|
|
await connection.execute(
|
2017-06-14 09:54:45 +08:00
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
2017-06-14 09:54:45 +08:00
|
|
|
},
|
2023-02-21 11:34:43 +08:00
|
|
|
// NJS-011: encountered bind value and type mismatch in parameter 2
|
|
|
|
/NJS-011:/
|
2017-06-14 09:54:45 +08:00
|
|
|
);
|
|
|
|
}); // 81.1.9
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.10 works with 0', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = 0;
|
2023-02-21 11:45:10 +08:00
|
|
|
await assert.rejects(
|
2023-02-21 11:34:43 +08:00
|
|
|
async () => {
|
|
|
|
await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
2017-06-14 09:54:45 +08:00
|
|
|
},
|
2023-02-21 11:34:43 +08:00
|
|
|
// NJS-011: encountered bind value and type mismatch in parameter 2
|
|
|
|
/NJS-011:/
|
2017-06-14 09:54:45 +08:00
|
|
|
);
|
|
|
|
}); // 81.1.10
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.11 works with String length 32K', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 32768;
|
|
|
|
const specialStr = "81.1.11";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, specialStr);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.11
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.12 works with String length (64K - 1)', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 65535;
|
|
|
|
const specialStr = "81.1.12";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, specialStr);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.12
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.13 works with String length (64K + 1)', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 65537;
|
|
|
|
const specialStr = "81.1.13";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, specialStr);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.13
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.14 works with String length (1MB + 1)', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 1048577; // 1 * 1024 * 1024 + 1;
|
|
|
|
const specialStr = "81.1.14";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
await insertIntoClobTable1(id, content);
|
|
|
|
await checkInsertResult(id, content, specialStr);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.14
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.15 bind value and type mismatch', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content = 100;
|
|
|
|
const sql = "INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)";
|
|
|
|
const binds = {
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
2023-02-21 11:34:43 +08:00
|
|
|
};
|
2023-02-21 11:45:10 +08:00
|
|
|
await assert.rejects(
|
2023-02-21 11:34:43 +08:00
|
|
|
async () => await connection.execute(sql, binds),
|
|
|
|
// NJS-011: encountered bind value and type mismatch in parameter 2
|
|
|
|
/NJS-011:/
|
2017-06-14 09:54:45 +08:00
|
|
|
);
|
|
|
|
}); // 81.1.15
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.16 mixing named with positional binding', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 40000;
|
|
|
|
const specialStr = "81.1.16";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
const result = await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:1, :2)",
|
|
|
|
[
|
2023-10-30 22:47:16 +08:00
|
|
|
id, { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
2023-02-21 11:34:43 +08:00
|
|
|
]);
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
|
|
|
await checkInsertResult(id, content, specialStr);
|
|
|
|
}); // 81.1.16
|
2017-06-14 09:54:45 +08:00
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.17 bind with invalid CLOB', async function() {
|
|
|
|
const id = insertID++;
|
2023-02-21 11:45:10 +08:00
|
|
|
await assert.rejects(
|
2023-02-21 11:34:43 +08:00
|
|
|
async () => {
|
|
|
|
await connection.execute(
|
2017-06-14 09:54:45 +08:00
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:1, :2)",
|
|
|
|
[
|
2023-10-30 22:47:16 +08:00
|
|
|
id, { val: {}, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
2023-02-21 11:34:43 +08:00
|
|
|
]);
|
2017-06-14 09:54:45 +08:00
|
|
|
},
|
2023-02-21 11:34:43 +08:00
|
|
|
// NJS-011: encountered bind value and type mismatch
|
|
|
|
/NJS-011:/
|
2017-06-14 09:54:45 +08:00
|
|
|
);
|
|
|
|
}); // 81.1.17
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.18 RETURNING INTO with bind type STRING', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 400;
|
|
|
|
const specialStr = "81.1.18";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
const sql = "INSERT INTO nodb_dml_clob_1 (id, clob) VALUES (:i, :c) RETURNING clob INTO :lobbv";
|
|
|
|
const result = await connection.execute(
|
|
|
|
sql,
|
|
|
|
{
|
|
|
|
i: id,
|
|
|
|
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
|
|
|
lobbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: contentLength }
|
|
|
|
},
|
|
|
|
{ autoCommit: false });
|
2023-05-03 18:32:09 +08:00
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
|
|
|
assert.strictEqual(result.outBinds.lobbv.length, 1);
|
2023-02-21 11:34:43 +08:00
|
|
|
await checkInsertResult(id, content, specialStr);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.1.18
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.1.19 works with bind in maxSize smaller than string length', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength = 32768;
|
|
|
|
const specialStr = "81.1.20";
|
|
|
|
const content = random.getRandomString(contentLength, specialStr);
|
|
|
|
const result = await connection.execute(
|
|
|
|
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
|
|
|
{
|
2023-10-30 22:47:16 +08:00
|
|
|
ID: { val: id },
|
|
|
|
C: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: 1 }
|
2023-02-21 11:34:43 +08:00
|
|
|
});
|
|
|
|
assert.strictEqual(result.rowsAffected, 1);
|
|
|
|
await checkInsertResult(id, content, specialStr);
|
2020-01-22 09:12:17 +08:00
|
|
|
}); // 81.1.19
|
2017-06-14 09:54:45 +08:00
|
|
|
|
|
|
|
}); // 81.1
|
|
|
|
|
|
|
|
describe('81.2 CLOB, UPDATE', function() {
|
|
|
|
insertID = 0;
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
before(async function() {
|
|
|
|
await executeSQL(proc_clob_1);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // before
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
after(async function() {
|
|
|
|
await executeSQL(sql2DropTable1);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // after
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.2.1 update EMPTY_CLOB column', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content_1 = "EMPTY_CLOB";
|
|
|
|
const contentLength_2 = 32768;
|
|
|
|
const specialStr_2 = "81.2.1";
|
|
|
|
const content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
|
|
|
await insertIntoClobTable1(id, content_1);
|
|
|
|
await checkInsertResult(id, content_1, null);
|
|
|
|
await updateClobTable1(id, content_2);
|
|
|
|
await checkInsertResult(id, content_2, specialStr_2);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.2.1
|
|
|
|
|
2024-05-10 18:29:33 +08:00
|
|
|
it('81.2.2 update a column with EMPTY_CLOB', async function() {
|
2023-02-21 11:34:43 +08:00
|
|
|
const id = insertID++;
|
|
|
|
const contentLength_1 = 50000;
|
|
|
|
const specialStr_1 = "81.2.2";
|
|
|
|
const content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
|
|
|
const content_2 = "EMPTY_CLOB";
|
|
|
|
await insertIntoClobTable1(id, content_1);
|
|
|
|
await checkInsertResult(id, content_1, specialStr_1);
|
|
|
|
await updateClobTable1(id, content_2);
|
|
|
|
await checkInsertResult(id, content_2, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.2.2
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.2.3 update EMPTY_CLOB column with empty string', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content_1 = "EMPTY_CLOB";
|
|
|
|
const content_2 = "";
|
|
|
|
await insertIntoClobTable1(id, content_1);
|
|
|
|
await checkInsertResult(id, content_1, null);
|
|
|
|
await updateClobTable1(id, content_2);
|
|
|
|
await checkInsertResult(id, content_2, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.2.3
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.2.4 update empty string column', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const content_1 = "";
|
|
|
|
const contentLength_2 = 54321;
|
|
|
|
const specialStr_2 = "81.2.4";
|
|
|
|
const content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
|
|
|
await insertIntoClobTable1(id, content_1);
|
|
|
|
await checkInsertResult(id, content_1, null);
|
|
|
|
await updateClobTable1(id, content_2);
|
|
|
|
await checkInsertResult(id, content_2, specialStr_2);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.2.4
|
|
|
|
|
2023-02-21 11:34:43 +08:00
|
|
|
it('81.2.5 update a column with empty string', async function() {
|
|
|
|
const id = insertID++;
|
|
|
|
const contentLength_1 = 50000;
|
|
|
|
const specialStr_1 = "81.2.2";
|
|
|
|
const content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
|
|
|
const content_2 = "";
|
|
|
|
await insertIntoClobTable1(id, content_1);
|
|
|
|
await checkInsertResult(id, content_1, specialStr_1);
|
|
|
|
await updateClobTable1(id, content_2);
|
|
|
|
await checkInsertResult(id, content_2, null);
|
2017-06-14 09:54:45 +08:00
|
|
|
}); // 81.2.5
|
|
|
|
|
|
|
|
}); // 81.2
|
2023-02-21 11:34:43 +08:00
|
|
|
|
2017-06-14 09:54:45 +08:00
|
|
|
});
|