Skip to content

Commit c03c135

Browse files
committed
Test owned property fix
1 parent 8e080a9 commit c03c135

File tree

4 files changed

+133
-5
lines changed

4 files changed

+133
-5
lines changed

test/aq2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,4 @@ describe('218. aq2.js', function() {
288288
should.not.exist(err);
289289
}
290290
}); // 218.7
291-
});
291+
});

test/examineOwnedProperties.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* NAME
19+
* 220. examineOwnedProperties.js
20+
*
21+
* DESCRIPTION
22+
* Add this test from GitHub issue 1129 to prevent regression.
23+
* https://github.com/oracle/node-oracledb/issues/1129
24+
*
25+
*****************************************************************************/
26+
'use strict';
27+
28+
const oracledb = require('oracledb');
29+
const should = require('should');
30+
const dbconfig = require('./dbconfig.js');
31+
const testsUtil = require('./testsUtil.js');
32+
33+
describe('220. examineOwnedProperties.js', () => {
34+
35+
let conn;
36+
const TABLE = "nodb_tab_rating";
37+
38+
before(async () => {
39+
try {
40+
conn = await oracledb.getConnection(dbconfig);
41+
42+
let sql = `
43+
CREATE TABLE ${TABLE} (
44+
"RATE_TIME" VARCHAR2(32),
45+
"RATE_USER" VARCHAR2(128),
46+
"ITEM_PRICE" NUMBER,
47+
"RATING" VARCHAR2(4000)
48+
)
49+
`;
50+
let plsql = testsUtil.sqlCreateTable(TABLE, sql);
51+
await conn.execute(plsql);
52+
} catch (err) {
53+
should.not.exist(err);
54+
}
55+
}); // before()
56+
57+
after(async () => {
58+
try {
59+
let sql = `DROP TABLE ${TABLE} PURGE`;
60+
await conn.execute(sql);
61+
conn.close();
62+
} catch (err) {
63+
should.not.exist(err);
64+
}
65+
}); // after()
66+
67+
it('220.1 Only examine "owned" properties on objects', async () => {
68+
try {
69+
const sql = `
70+
MERGE INTO ${TABLE} R USING (
71+
SELECT
72+
:item_price as itemPrice,
73+
:rate_time as rateTime,
74+
:rate_user as rateUser,
75+
:rating as rating
76+
FROM DUAL ) T ON (
77+
R.RATE_TIME = T.rateTime
78+
AND R.RATE_USER = T.rateUser
79+
) WHEN MATCHED THEN UPDATE SET
80+
R.ITEM_PRICE = T.itemPrice
81+
, R.RATING = T.rating
82+
WHEN NOT MATCHED THEN INSERT (
83+
RATE_TIME
84+
, RATE_USER
85+
, ITEM_PRICE
86+
, RATING
87+
) VALUES (
88+
T.rateTime
89+
, T.rateUser
90+
, T.itemPrice
91+
, T.rating
92+
)
93+
`;
94+
const data = [
95+
{ "rate_user": "Bob",
96+
"rate_time": "2019-07-26 19:42:36",
97+
"item_price":338,
98+
"rating":"I like it"
99+
},
100+
{ "rate_user": "Alice",
101+
"rate_time": "2019-07-26 19:42:36",
102+
"item_price":338,
103+
"rating":"I like it too"
104+
}
105+
];
106+
const options = {
107+
autoCommit: true,
108+
bindDefs: {
109+
item_price : { type: oracledb.NUMBER },
110+
rate_time : { type: oracledb.STRING, maxSize: 32 },
111+
rate_user : { type: oracledb.STRING, maxSize: 128 },
112+
rating : { type: oracledb.STRING, maxSize: 4000 },
113+
}
114+
};
115+
116+
Object.prototype.noop = () => {};
117+
118+
await conn.executeMany(sql, data, options);
119+
120+
} catch (err) {
121+
should.not.exist(err);
122+
}
123+
}); // 220.1
124+
});

test/list.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4612,4 +4612,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
46124612
219.4 Negative - Set "maxMessages" argument to be -5
46134613
219.5 Negative - Set "maxMessages" argument to be 0
46144614
219.6 Enqueue a Buffer
4615-
219.7 enqMany() mixes enqueuing string and buffer
4615+
219.7 enqMany() mixes enqueuing string and buffer
4616+
4617+
220. examineOwnedProperties.js
4618+
220.1 Only examine "owned" properties on objects

test/opts/mocha.opts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ test/fetchBinaryTypesAsString.js
220220
test/currentSchema.js
221221

222222
test/implicitResults.js
223-
224223
test/getDataOfLob.js
225-
226224
test/dbObjectsNestTbl.js
227225

228226
test/dbObject1.js
@@ -244,4 +242,7 @@ test/dbObject16.js
244242
test/dbObject17.js
245243

246244
test/aq1.js
247-
test/aq2.js
245+
test/aq2.js
246+
test/aq3.js
247+
248+
test/examineOwnedProperties.js

0 commit comments

Comments
 (0)