Skip to content

Commit 6b78afe

Browse files
committed
Handle alias name in SELECTs which are part of a super class
1 parent 16af6c1 commit 6b78afe

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
**This release is under development and information may be incomplete**
66

7+
- Fixed numeric suffix feature (for duplicate SELECT column names when using
8+
`oracledb.OUT_FORMAT_OBJECT` mode) when the column name is also a JavaScript
9+
property or method name.
10+
711
- Added missing support for binding as `oracledb.DB_TYPE_BINARY_INTEGER`.
812

913
## node-oracledb v5.3.0 (22 Oct 2021)

src/njsResultSet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ bool njsResultSet_makeUniqueColumnNames(napi_env env, njsBaton *baton,
522522
NJS_CHECK_NAPI(env, napi_create_string_utf8(env, queryVars[col].name,
523523
queryVars[col].nameLength, &queryVars[col].jsName))
524524

525-
NJS_CHECK_NAPI(env, napi_has_property(env, tempObj,
525+
NJS_CHECK_NAPI(env, napi_has_own_property(env, tempObj,
526526
queryVars[col].jsName, &exists))
527527
if (!exists) {
528528
NJS_CHECK_NAPI(env, napi_create_uint32(env, col, &colObj))

test/dataTypeRowid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. */
1+
/* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. */
22

33
/******************************************************************************
44
*

test/dupColNames1.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,30 @@ describe('246. dupColNames1.js', function() {
608608
assert.equal(result.rows[0].DEPARTMENT_ID_499, 101);
609609
assert.equal(result.rows[0].DEPARTMENT_ID_1000, 101);
610610
});
611+
612+
613+
it('246.1.19 Negative not-case sensitive prop name', async function() {
614+
// alias name is within quotes and so does not match any string
615+
// comparison
616+
const sql =
617+
`SELECT
618+
A.EMPLOYEE_ID, A.DEPARTMENT_ID,
619+
B.department_id, B.department_id AS "toString"
620+
FROM nodb_dupEmployee A, nodb_dupDepartment B
621+
WHERE A.department_id = B.department_id
622+
ORDER BY A.EMPLOYEE_ID`;
623+
624+
const result = await connection.execute(sql);
625+
assert.equal(result.metaData[0].name, "EMPLOYEE_ID");
626+
assert.equal(result.metaData[1].name, "DEPARTMENT_ID");
627+
assert.equal(result.metaData[2].name, "DEPARTMENT_ID_1");
628+
assert.equal(result.metaData[3].name, "toString");
629+
assert.equal(result.rows[0].EMPLOYEE_ID, 1001);
630+
assert.equal(result.rows[0].DEPARTMENT_ID, 101);
631+
assert.equal(result.rows[0].DEPARTMENT_ID_1, 101);
632+
assert.equal(result.rows[0].toString, 101);
633+
});
634+
611635
});
612636

613637
describe('246.2 Duplicate column names, query with ResultSet', function() {

test/list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,6 +4945,9 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
49454945
246.1.15 Duplicate column with non-conflicting alias name using REF cursor
49464946
246.1.16 Duplicate column with case sensitive alias name using REF cursor
49474947
246.1.17 Duplicate column with case sensitive alias name from dual
4948+
246.1.18 1000 duplicate columns
4949+
246.1.19 Negative not-case sensitive prop name
4950+
49484951
246.2 Duplicate Column Names, query with ResultSet
49494952
246.2.1 Two duplicate columns
49504953
246.2.2 Three duplicate columns

0 commit comments

Comments
 (0)